#includereg52.h>#define uint unsigned int#define uchar unsigned charuchar code temp[]={0x80,0xe3,0x44,0x41,0x23,0x11,0x10,0xc3,0x00,0x01};
//數(shù)碼管由0~9的顯示char code b[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f,0xbf,
0xdf,0xef,0xf7,0xfb,0xfd,0xfe,0xfc,0xf8,0xf0,0xe0,0xc0,0x80,0x00,0x01,0x03,0x07,0x0f,0x1f,
0x3f,0x7f,0xff,0x7f,0x3f,0x1f,0x0f,0x07,0x03,0x01,0x00};//流水燈先是逐個(gè)閃動(dòng),
后反向閃動(dòng),再全部閃動(dòng),再反向全部閃動(dòng)。void delay(uint time)//延時(shí)函數(shù){while(time--);}void main() //主函數(shù){uint k,l;uchar i,j;j=0;while(1){for(i=0;i10;i++){P1=temp;P2=b[j]; for(l=0;l100;l++)for(k=0;k5;k++)delay(10);j++;if(j==38)j=0;}}}缺點(diǎn):?jiǎn)纹瑱C(jī)兩個(gè)IO口不能同時(shí)獨(dú)立工作!
評(píng)論