兩片74HC595級聯(lián)驅(qū)動8個數(shù)碼管_第1頁
兩片74HC595級聯(lián)驅(qū)動8個數(shù)碼管_第2頁
兩片74HC595級聯(lián)驅(qū)動8個數(shù)碼管_第3頁
兩片74HC595級聯(lián)驅(qū)動8個數(shù)碼管_第4頁
兩片74HC595級聯(lián)驅(qū)動8個數(shù)碼管_第5頁
已閱讀5頁,還剩1頁未讀 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

1、兩片74HC595級聯(lián)動態(tài)驅(qū)動8位數(shù)碼管 51單片機(jī)#include <reg52.h>sbit SCK = P11;    / 數(shù)據(jù)輸入時鐘線,脈沖sbit SI  = P10;    / 數(shù)據(jù)線sbit RCK = P12;    / 鎖存unsigned char code SMG10 = 0xC0, 0xF9, 0xA4, 0xB0, 0x99, 0x92, 0x82, 0xF8, 0x80, 0x90;  / 段碼unsigned char code W

2、ei8 = 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80;    / 位選unsigned char Val8  = 0;    / 要顯示的數(shù)據(jù) * 函數(shù)聲明 *void interrupt_init(void);void timer_init(void);  控制74HC595輸出數(shù)據(jù)void Output(void)    RCK = 0;    RCK = 1; 向74H

3、C595中寫入一字節(jié)數(shù)據(jù)void Write_Byte(unsigned char dat)    unsigned char i = 0;       for(i=0; i<8; i+)            SCK = 0;        SI  = dat & 0x80;   &

4、#160;    SCK = 1;               dat <<= 1;           顯示函數(shù)void Display(unsigned char * p)    unsigned char * pt = Wei;    

5、60;  Write_Byte(*(pt+0);    Write_Byte(SMG*(p+7);    Output();       Write_Byte(*(pt+1);    Write_Byte(SMG*(p+6);    Output();       Write_Byte(*(pt+2);    Writ

6、e_Byte(SMG*(p+5);    Output();       Write_Byte(*(pt+3);    Write_Byte(SMG*(p+4);    Output();        Write_Byte(*(pt+4);    Write_Byte(SMG*(p+3);    Output();&

7、#160;      Write_Byte(*(pt+5);    Write_Byte(SMG*(p+2);    Output();       Write_Byte(*(pt+6);    Write_Byte(SMG*(p+1);    Output();       Write_Byte(*(pt+

8、7);    Write_Byte(SMG*(p+0);    Output();    int main(void)       timer_init();    interrupt_init();       while(1)           

9、; Display(Val);           return 0;void interrupt_init(void) EA  = 1;  /開總中斷 ET0 = 1;  /開定時器0中斷 ET1 = 1;  /開定時器1中斷void timer_init(void) TMOD = TMOD | 0x01;  /定時器0工作方式1 TMOD = TMOD &

10、 0xFD;    TH0  = 0x4B;   /裝初值,50ms計(jì)數(shù) TL0  = 0xFF; TR0  = 1;    /開啟定時器0void timer0() interrupt 1    static unsigned char counter0 = 0; counter0+; TH0  = 0x4B;   /重新裝入初值,定時器0從頭開

11、始計(jì)數(shù),計(jì)數(shù)50ms   TL0  = 0xFF;  if(2 = counter0)  /2*50 ms = 100ms = 0.1s   counter0 = 0;  /counter0置零,定時器0從頭開始計(jì)數(shù)               Val0+;      

12、  if(10=Val0)                    Val0 = 0;            Val1+;               

13、        if(10=Val1)                            Val1 = 0;             &

14、#160;  Val2+;                               if(10=Val2)               

15、                     Val2 = 0;                    Val3+;         

16、                              if(10=Val3)                   

17、                         Val3 = 0;                        Val4+; 

18、                                              if(10=Val4)   

19、                                                 Val4 = 0; &

20、#160;                          Val5+;                       

21、                                if(10=Val5)                 

22、                                           Val5 = 0;       &

23、#160;                        Val6+;                         

24、                                      if(10=Val6)           

25、                                                   

26、;      Val6 = 0;                                    Val7+;       

27、                                                  

28、              if(10=Val7)                                   

29、                                         Val7 = 0;         &#

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論