久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 2465|回復: 0
打印 上一主題 下一主題
收起左側

今晚不加班,躺在床上想了想

[復制鏈接]
跳轉到指定樓層
樓主
ID:72519 發表于 2015-1-23 00:51 | 只看該作者 回帖獎勵 |倒序瀏覽 |閱讀模式

  1. 寫了4個信號分兩組處理,1Hz,2Hz,8Hz,16Hz
  2. 不多說,看電完電視后,來上程序了!
  3. //#pragma src(signle.a51)
  4. #include <reg52.h>
  5. #include <display.c>
  6. #define uchar unsigned char
  7. #define uint unsigned int
  8. //sfr PCON = 0x87h;
  9. sbit Key1 = P3^2;
  10. sbit BUZ = P3^1;
  11. sbit Signle = P3^0;
  12. sbit Led0  = P1^0;
  13. sbit JDQ  = P1^2;
  14. sbit Dp = P1^5;
  15. sbit SMG1 = P3^7;
  16. sbit SMG2 = P3^5;
  17. sbit SMG3 = P3^4;
  18. sbit SMG4 = P3^3;
  19. uint Key_count,Time_value,Time_Count,BTime_Count;
  20. uchar Beep_time,Key_flag,BTime_Flag,JDQ_flag,BP_Count,LM_Count,LM_GroupCNT;
  21. uchar BT_Sec,Sec,Min,Hour,Key_Select,Key_long_flag,Key_long_count;
  22. uchar Led_Scan,Led_Loop,Sec_1,Min_1,Hour_1,BT_Sec_1;
  23. uchar Key_Select_Flag,BT_4Sec;
  24. //uchar Display_number[]={0xd7,0x14,0xcd,0x5d,0x1e,0x5b,0xdb,0x15,0xdf,0x5f,0x00};
  25. uchar code Display_number[]={0xff,0xff,0x28,0xeb,0x32,0xa2,0xe1,0xa4,0x24,0xea,0x20,0xa0,0xf7,0xff}; //0123456789 -
  26. uchar code Display_string_1Hz[]={0xff,0xff,0xff,0xf7,0xeb,0x61,0x32,0xf7,0xff,0xff,0xff,0xff,0xff,0xff};//-1HZ-
  27. uchar code Display_string_2Hz[]={0xff,0xff,0xff,0xf7,0x32,0x61,0x32,0xf7,0xff,0xff,0xff,0xff,0xff,0xff};//-2HZ-
  28. uchar code Display_string_8Hz[]={0xff,0xff,0xff,0xf7,0x20,0x61,0x32,0xf7,0xff,0xff,0xff,0xff,0xff,0xff};//-8HZ-
  29. uchar code Display_string_16Hz[]={0xff,0xff,0xff,0xf7,0xeb,0x24,0x61,0x32,0xf7,0xff,0xff,0xff,0xff,0xff,0xff};//-16HZ-
  30. uchar Clock[]={0xff,0xff,0xff,0xeb,0x32,0xf7,0xeb,0x32,0xf7,0xeb,0x32,0xff,0xff,0xff,0xff,0xff,0xff,0xff};
  31. //---------------------------------------------------
  32. //---------------------------------------------------
  33. //4COM 共陽數碼管 1234        SR410361K       
  34. //---------------------------------------------------  
  35. //P1.0 A;         |---|
  36. //P1.2 B;         |   |
  37. //P1.4 C;         |---|
  38. //P1.6 D;         |   |
  39. //P1.7 E;         |---|
  40. //P1.1 F;
  41. //P1.3 G;
  42. //P1.5 Dp;
  43. //SMG1=P3.7,SMG2=P3.5,SMG3=P3.4,SMG4=P3.3;
  44. //---------------------------------------------------
  45. //---------------------------------------------------
  46. void display_Scan(void);
  47. void Delay_ms();
  48. void Delay_ms(uint Tms)
  49. {
  50. uint i,j;
  51. for(i=Tms;i>0;i--)
  52. for(j=1220;j>0;j--)
  53. {;}
  54. }
  55. void Delay_us(uint Tus)
  56. {
  57. while(--Tus);
  58. }
  59. void Buz(void)
  60.         {
  61.   uint i;
  62.   for(i=0;i<200;i++)
  63.   {
  64.            BUZ=~BUZ;
  65.   Delay_us(300);
  66.   }
  67.   BUZ=0;
  68.         }
  69. void Beep_Bi(void)
  70. {
  71. if(Beep_time!=0)
  72. {
  73. Beep_time--;
  74. BUZ=~BUZ;
  75. }
  76. else
  77. {
  78. BUZ=0;
  79. }
  80. }

  81. void T0_ini()
  82. {
  83. TMOD=0x12;
  84. TH1=(65536-1000)/256;
  85. TL1=(65536-1000)%256;
  86. TR1=1;
  87. ET1=1;

  88. TH0=6;
  89. TL0=6;

  90. TR0=0;
  91. ET0=1;       
  92. EA=1;
  93. }

  94. void TM0(void)interrupt 1
  95. {
  96. //uint Time_Count,BTime_Count;
  97. TF0=0;       
  98. Time_Count++;BTime_Count++;BP_Count++;
  99. if(BTime_Count==1000)
  100. {
  101. BTime_Count=0;BT_Sec++;
  102. if(BT_Sec==2)
  103. {
  104. BT_Sec=0;BTime_Flag=~BTime_Flag;BT_4Sec++;
  105. if(BT_4Sec==8)
  106. {
  107. BT_4Sec=0;Key_Select=0;
  108. }

  109. }
  110. }
  111. if(BP_Count==2)          //1ms DiDa Batime;
  112. {
  113. BP_Count=0;
  114. Beep_Bi();
  115. }
  116. if(Key_Select_Flag==1)         //1Hz
  117. {
  118. if(Time_Count==2000)
  119. {
  120. Time_Count=0;Dp=~Dp;Signle=~Signle;
  121. }                
  122. }
  123. if(Key_Select_Flag==2) //2Hz
  124. {
  125. if(Time_Count==1000)        //500 4Hz//250 8Hz//125 16Hz
  126. {
  127. Time_Count=0;Dp=~Dp;Signle=~Signle;
  128. }
  129. }
  130. if(Key_Select_Flag==3)        //8Hz
  131. {
  132.   if(Time_Count==250)
  133. {
  134. Time_Count=0;Dp=~Dp;Signle=~Signle;       
  135. }
  136. }
  137. if(Key_Select_Flag==4)        //16Hz
  138. {
  139. if(Time_Count==125)
  140. {       
  141. Time_Count=0;Dp=~Dp;Signle=~Signle;
  142. }
  143. }
  144.   //if(Time_Count==2000)        // ext atxl 12MHz;500ms
  145. //if(Time_Count==1333)        // ext atxl 8MHz 500ms;
  146. //if(Time_Count==998)        // built in atxl; 500ms
  147. }

  148. void TM1(void)interrupt 3
  149. {
  150. TH1=(65536-1000)/256;
  151. TL1=(65536-1000)%256;
  152. Led_Scan=1;Led_Loop++;Led_Loop=Led_Loop&0x03;

  153.         Key1=1;
  154.         if(Key1==0)
  155.         {
  156.         Key_count++;
  157. if(Key_count==20)
  158. {
  159. Beep_time=100;Key_flag=1;
  160. BTime_Count=0;BT_Sec=0;BT_4Sec=0;Time_Count=0;
  161. TR0=1;Key_Select++;
  162. if(Key_Select==5)
  163. {
  164.         Key_Select=0;Key_Select_Flag=0;Key_flag=0;TR0=0;
  165. }
  166.      if(Key_Select==1)
  167. {       
  168. Key_Select_Flag=0;Key_Select_Flag=1;
  169. }
  170. if(Key_Select==2)
  171. {
  172. Key_Select_Flag=0;Key_Select_Flag=2;
  173.      }       
  174. if(Key_Select==3)
  175. {
  176.   Key_Select_Flag=0;Key_Select_Flag=3;
  177. }  
  178.   if(Key_Select==4)
  179. {
  180.   Key_Select_Flag=0;Key_Select_Flag=4;
  181. }  
  182. }
  183. }
  184.         else
  185. {Key_count=0;Key_long_flag=0;}
  186. }

  187. void SmgDisp(uchar ch,uchar num)
  188. {
  189. uchar number;
  190. number=num;
  191. //P3=0x03;
  192. P1=0xff;
  193. SMG1=0;SMG2=0;SMG3=0;SMG4=0;
  194. switch(ch)
  195. {
  196. case 1:SMG4=1;LM_Count=0;break;          //SMG排列 1 2 3 4        第四個數碼管
  197. case 2:SMG3=1;LM_Count++;break;          //SMG排列 1 2 3 4        第三個數碼管
  198. case 3:SMG2=1;LM_Count++;break;          //SMG排列 1 2 3 4        第二個數碼管
  199. case 4:SMG1=1;LM_Count++;break;          //SMG排列 1 2 3 4        第一個數碼管
  200. default:break;
  201. }
  202. if((Key_Select==0)&(Key_Select_Flag==1))
  203. {        P1=Display_string_1Hz[number];        }
  204. else if((Key_Select==0)&(Key_Select_Flag==2))
  205. {        P1=Display_string_2Hz[number];        }
  206. else if((Key_Select==0)&(Key_Select_Flag==3))
  207. {        P1=Display_string_8Hz[number];        }
  208. else if((Key_Select==0)&(Key_Select_Flag==4))
  209. {        P1=Display_string_16Hz[number];        }
  210. else
  211. P1=Display_number[number];
  212. }

  213. void CheckTime()
  214. {
  215. if(Led_Scan)
  216. {
  217. switch(Led_Loop)
  218. {
  219. case 0:SmgDisp(4,LM_Count+LM_GroupCNT);break; //第一個數碼管
  220. case 1:SmgDisp(3,LM_Count+LM_GroupCNT);break; //第二個數碼管
  221. case 2:SmgDisp(2,LM_Count+LM_GroupCNT);break; //第三個數碼管
  222. case 3:SmgDisp(1,LM_Count+LM_GroupCNT);break; //第四個數碼管
  223. }
  224.   Led_Scan=0;
  225. }
  226. }
  227. void Display(void)
  228. {
  229. if((Key_Select==1)||(Key_Select==2))
  230.         {
  231. if((BTime_Flag)&(Key_Select==1)&(Key_Select_Flag==1))
  232. {       
  233. P1=0xff;SMG1=0;SMG2=0;SMG3=0;SMG4=0;        //P3=0x00;
  234. }
  235. else
  236. {
  237. if(BTime_Flag)
  238. {
  239. Dp=0;SMG1=1;        //P3=0x80;
  240. Delay_ms(1);SMG1=0;        //P3=0x00;
  241. Dp=0;SMG2=1;        //P3=0x20;
  242. Delay_ms(1);SMG2=0;        //P3=0x00;
  243. }       
  244. P1=Display_string_1Hz[4];
  245. SMG1=1;        //P3=0x80;
  246. Delay_ms(1);
  247. SMG1=0;        //P3=0x00;
  248. P1=0xff;
  249. P1=Display_string_1Hz[5];
  250. SMG2=1;        //P3=0x20;
  251. Delay_ms(1);
  252. SMG2=0;        //P3=0x00;
  253. P1=0xff;
  254. }
  255. if((BTime_Flag)&(Key_Select==2)&(Key_Select_Flag==2))
  256. {
  257. P1=0xff;SMG1=0;SMG2=0;SMG3=0;SMG4=0;        //P3=0x00;
  258. }
  259. else
  260. {
  261. if(BTime_Flag)
  262. {
  263. Dp=0;SMG3=1;        //P3=0x10;
  264. Delay_ms(1);SMG3=0;        //P3=0x00;
  265. Dp=0;SMG4=1;        //P3=0x08;
  266. Delay_ms(1);SMG4=0;        //P3=0x00;
  267. }       
  268. P1=Display_string_2Hz[4];
  269. SMG3=1;        //P3=0x10;
  270. Delay_ms(1);
  271. SMG3=0;        //P3=0x00;
  272. P1=0xff;
  273. P1=Display_string_2Hz[5];
  274. SMG4=1;        //P3=0x08;
  275. Delay_ms(1);
  276. SMG4=0;        //P3=0x00;
  277. P1=0xff;
  278. }
  279.         }
  280.         else
  281. if((Key_Select==3)||(Key_Select==4))
  282.         {
  283.         if((BTime_Flag)&(Key_Select==3)&(Key_Select_Flag==3))
  284. {
  285. P1=0xff;SMG1=0;SMG2=0;SMG3=0;SMG4=0;        //P3=0x00;
  286. }
  287.         else
  288. {
  289. if(BTime_Flag)
  290. {
  291. Dp=0;SMG1=1;
  292. Delay_ms(1);SMG1=0;        //P3=0x00;
  293. Dp=0;SMG2=1;        //P3=0x08;
  294. Delay_ms(1);SMG2=0;        //P3=0x00;
  295. }       
  296. P1=Display_string_8Hz[4];
  297. SMG1=1;        //P3=0x10;
  298. Delay_ms(1);
  299. SMG1=0;        //P3=0x00;
  300. P1=0xff;
  301. P1=Display_string_8Hz[5];
  302. SMG2=2;        //P3=0x08;
  303. Delay_ms(1);
  304. SMG2=0;        //P3=0x00;
  305. P1=0xff;
  306. }
  307. if((BTime_Flag)&(Key_Select==4)&(Key_Select_Flag==4))
  308. {
  309. P1=0xff;SMG1=0;SMG2=0;SMG3=0;SMG4=0;        //P3=0x00;
  310. }
  311. else
  312. {
  313. if(BTime_Flag)
  314. {
  315. Dp=0;SMG3=1;        //P3=0x10;
  316. Delay_ms(1);SMG3=0;        //P3=0x00;
  317. Dp=0;SMG4=1;        //P3=0x08;
  318. Delay_ms(1);SMG4=0;        //P3=0x00;
  319. }       
  320. P1=Display_string_16Hz[4];
  321. SMG3=1;        //P3=0x10;
  322. Delay_ms(1);
  323. SMG3=0;        //P3=0x00;
  324. P1=0xff;
  325. P1=Display_string_16Hz[5];
  326. SMG4=1;        //P3=0x08;
  327. Delay_ms(1);
  328. SMG4=0;        //P3=0x00;
  329. P1=0xff;
  330. }
  331.         }
  332. }

  333. void exint0(void)interrupt 0
  334. {
  335. Buz();T0_ini();EX0=0;EA=1;
  336. }

  337. void Display_Scan(void)
  338. {       
  339. P1=0x00;
  340. P3=0x00;
  341. //---------"A"--------------p1.0
  342. //P1=0x01;
  343. P1=0xfe;
  344. P3=0x80;         //smg1
  345. Delay_ms(5);
  346. P1=0xff;
  347. P3=0x00;
  348. P1=0xfe;
  349. P3=0x20;         //smg2
  350. Delay_ms(5);
  351. P1=0xff;
  352. P3=0x00;
  353. P1=0xfe;
  354. P3=0x10;         //smg3
  355. Delay_ms(5);
  356. P1=0xff;
  357. P3=0x00;
  358. P1=0xfe;
  359. P3=0x08;         //smg4
  360. Delay_ms(5);
  361. P1=0xff;
  362. P3=0x00;
  363. P1=0xfe;
  364. P3=0x40;
  365. Delay_ms(250);
  366. //---------"B"--------------p1.2
  367. P1=0xfb;
  368. P3=0x80;
  369. Delay_ms(5);
  370. P1=0xff;
  371. P3=0x00;
  372. P1=0xfb;
  373. P3=0x20;
  374. Delay_ms(5);
  375. P1=0xff;
  376. P3=0x00;
  377. P1=0xfb;
  378. P3=0x10;
  379. Delay_ms(5);
  380. P1=0xff;
  381. P3=0x00;
  382. P1=0xfb;
  383. P3=0x08;       
  384. Delay_ms(5);
  385. P1=0xff;
  386. P3=0x00;
  387. P1=0xfb;
  388. P3=0x40;       
  389. Delay_ms(250);
  390. //---------"C"--------------p1.4
  391. //P1=0x10;
  392. P1=0xef;
  393. P3=0x80;
  394. Delay_ms(5);
  395. P1=0xff;
  396. P3=0x00;
  397. P1=0xef;
  398. P3=0x20;
  399. Delay_ms(5);
  400. P1=0xff;
  401. P3=0x00;
  402. P1=0xef;
  403. P3=0x10;
  404. Delay_ms(5);
  405. P1=0xff;
  406. P3=0x00;
  407. P1=0xef;
  408. P3=0x08;
  409. Delay_ms(5);
  410. P1=0xff;
  411. P3=0x00;
  412. P1=0xef;
  413. P3=0x40;
  414. Delay_ms(250);
  415. //---------"D"--------------p1.6  
  416. //-----p1.7 p1.6 p1.5 p1.4 p1.3 p1.2 p1.1 p1.0---//
  417. //-------1011 1111-------------------------------//
  418. P1=0xbf;
  419. P3=0x80;
  420. Delay_ms(5);
  421. P1=0xff;
  422. P3=0x00;
  423. P1=0xbf;
  424. P3=0x20;
  425. Delay_ms(5);
  426. P1=0xff;
  427. P3=0x00;
  428. P1=0xbf;
  429. P3=0x10;
  430. Delay_ms(5);
  431. P1=0xff;
  432. P3=0x00;
  433. P1=0xbf;
  434. P3=0x08;
  435. Delay_ms(5);
  436. P1=0xff;
  437. P3=0x00;
  438. P1=0xbf;
  439. P3=0x40;       
  440. Delay_ms(250);
  441. //---------"E"--------------p1.7
  442. P1=0x7f;
  443. P3=0x80;
  444. Delay_ms(5);
  445. P1=0xff;
  446. P3=0x00;
  447. P1=0x7f;
  448. P3=0x20;
  449. Delay_ms(5);
  450. P1=0xff;
  451. P3=0x00;
  452. P1=0x7f;
  453. P3=0x10;
  454. Delay_ms(5);
  455. P1=0xff;
  456. P3=0x00;
  457. P1=0x7f;
  458. P3=0x08;
  459. Delay_ms(5);
  460. P1=0xff;
  461. P3=0x00;
  462. P1=0x7f;
  463. P3=0x40;
  464. Delay_ms(250);
  465. //---------"F"--------------p1.1
  466. P1=0xfd;
  467. P3=0x80;
  468. Delay_ms(5);
  469. P1=0xff;
  470. P3=0x00;
  471. P1=0xfd;
  472. P3=0x20;
  473. Delay_ms(5);
  474. P1=0xff;
  475. P3=0x00;
  476. P1=0xfd;
  477. P3=0x10;
  478. Delay_ms(5);
  479. P1=0xff;
  480. P3=0x00;
  481. P1=0xfd;
  482. P3=0x08;
  483. Delay_ms(5);
  484. P1=0xff;
  485. P3=0x00;
  486. P1=0xfd;
  487. P3=0x40;
  488. Delay_ms(250);
  489. //---------"G"--------------p1.3
  490. P1=0xf7;
  491. P3=0x80;
  492. Delay_ms(5);
  493. P1=0xff;
  494. P3=0x00;
  495. P1=0xf7;
  496. P3=0x20;
  497. Delay_ms(5);
  498. P1=0xff;
  499. P3=0x00;
  500. P1=0xf7;
  501. P3=0x10;
  502. Delay_ms(5);
  503. P1=0xff;
  504. P3=0x00;
  505. P1=0xf7;
  506. P3=0x08;
  507. Delay_ms(5);
  508. P1=0xff;
  509. P3=0x00;
  510. P1=0xf7;
  511. P3=0x40;
  512. //------------------------------       
  513. P1=0x00;
  514. P3=0xfc;
  515. Delay_ms(500);
  516. //------------------------------
  517. P1=0x00;
  518. P3=0x80;
  519. Delay_ms(100);   //smg1
  520. P1=0x00;
  521. P3=0x20;
  522. Delay_ms(100);        //smg2
  523. P1=0x00;
  524. P3=0x10;
  525. Delay_ms(100);        //smg3
  526. P1=0x00;
  527. P3=0x08;        //smg4
  528. Delay_ms(100);

  529. P1=0x00;
  530. P3=0xfc;
  531. Delay_ms(250);       
  532. P1=0xff;
  533. P3=0x00;
  534. Delay_ms(250);
  535. P1=0x00;
  536. P3=0xfc;
  537. Delay_ms(250);
  538. }

  539. void main(void)
  540. {
  541. uint k;
  542. Buz();Display_Scan();                                                                            
  543. T0_ini();
  544. while(1)
  545. {
  546. ///*/-------------按鍵小于2次有分鐘睡眠模式-----------------
  547. if(Hour==4)
  548. {
  549. EX0=1;
  550. EA=1;
  551. Key_flag=0;
  552. Min_1=0;
  553. Hour_1=0;          
  554. Signle=1;
  555. TR0=1;
  556. P1=0xff;
  557. PCON=0x02;       
  558. }
  559. ////---------------------------------------------------------         */
  560. if(Key_Select==0)
  561. {       
  562. //for(LM_GroupCNT=0;LM_GroupCNT<13;LM_GroupCNT++)//拉幕時鐘時分秒顯示
  563. for(LM_GroupCNT=0;LM_GroupCNT<10;LM_GroupCNT++)
  564. {
  565. for(k=65500;k>0;k--)
  566. {
  567. CheckTime();
  568. }
  569. }
  570. }
  571. else
  572. Display();
  573. }
  574. }
復制代碼


分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏 分享淘帖 頂 踩
回復

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規則

手機版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術交流QQ群281945664

Powered by 單片機教程網

快速回復 返回頂部 返回列表
主站蜘蛛池模板: 国产在线一区二区三区 | 91网站视频在线观看 | 欧美精品一区二区在线观看 | 国产91在线观看 | 日韩成人在线电影 | 久久一视频| 亚洲国产精品一区在线观看 | 日韩精品四区 | 亚洲精品在线播放 | 亚洲国产精品久久 | 亚洲精品视频在线看 | 成人精品国产免费网站 | 羞羞视频网站免费观看 | 国产在线网站 | 亚洲一区二区三区在线视频 | 国产成人99久久亚洲综合精品 | 国产精品久久久久久久久免费樱桃 | 免费在线国产视频 | 国产成人综合在线 | 97视频在线免费 | 一区二区三区精品视频 | 国产成人精品久久久 | 色婷婷综合久久久中字幕精品久久 | 91精品国产91久久久久久吃药 | 欧美日韩免费在线 | 日韩精品一区二区三区第95 | 亚洲日韩中文字幕 | 欧美在线国产精品 | 国产乱码精品一品二品 | 99精品网 | 国产免费观看一级国产 | 国产精品欧美精品 | 人人做人人澡人人爽欧美 | 久久性 | 亚洲区一区二 | 国产亚洲二区 | 国产片一区二区三区 | 国产美女在线免费观看 | 91麻豆蜜桃一区二区三区 | 日日操日日干 | av手机在线 |