標(biāo)題: 單片機(jī)數(shù)碼管動(dòng)態(tài)掃描 [打印本頁(yè)]

作者: liuda    時(shí)間: 2015-1-21 23:31
標(biāo)題: 單片機(jī)數(shù)碼管動(dòng)態(tài)掃描
是用51hei單片機(jī)開(kāi)發(fā)板 電路圖詳見(jiàn):http://www.torrancerestoration.com/f/51hei-5.pdf  的數(shù)碼管部分, 用2個(gè)74hc573 鎖存,p0口作為數(shù)據(jù)口 ,注意圖中要改一下p3.6和p3.7分別是段和位的鎖存端口.P2口上面是按鍵 p1口上面是8個(gè)led燈.
  1. #include<reg52.h>
  2. #define uchar unsigned char
  3. #define uint unsigned int
  4. uchar code DIS_SEG7[16]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};
  5. uchar code DIS_BIT[8]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
  6. sbit D=P3^6;
  7. sbit V=P3^7;
  8. //==============
  9. void delay(uint k)
  10. {
  11. uint data i,j;
  12. for(i=0;i<k;i++){
  13. for(j=0;j<121;j++)
  14. {;}}
  15. }
  16. //===================
  17. void main(void)
  18. {
  19. uchar cnt;
  20. while(1)
  21. {
  22. for(cnt=0;cnt<8;cnt++)
  23. {D=1;P0=DIS_SEG7[cnt+1];D=0;P0=0xff;V=1;P0=DIS_BIT[cnt];V=0;
  24. delay(1);}
  25.    }
  26. }
復(fù)制代碼







歡迎光臨 (http://www.torrancerestoration.com/bbs/) Powered by Discuz! X3.1