74ls164做的跑馬燈c51程序
c51 74hc164--165--595c51
51單片機驅動74ls164跑馬燈,好處是只用了2個端口即可實現(xiàn),電路如下圖所示:
#includereg51.h>#includeintrins.h>#define uint unsigned int#define uchar unsigned charsbit dat=P2^6;sbit clk=P2^7;uchar ii;uchar code seg7code[]=
{0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80,0x00,0xff};//0-9,-,全滅void sendbyte(uchar seg){uchar num,c;num=seg7code[seg];for(c=0;c8;c++){dat=num0x80;num=_crol_(num,1);clk=0;clk=1;}}void delayms(int ms){uchar mi,mj;for(;ms>0;ms--)for(mi=6;mi>0;mi--)for(mj=82;mj>0;mj--);}void main(){for(ii=0;ii10;ii++){sendbyte(ii);delayms(200);}}
51單片機相關文章:51單片機教程
c++相關文章:c++教程
評論