|
用51单片机实现走马灯- #include<reg51.h>
- #define LED P0
- unsigned char table[]={0xfe,0xfd,0xfb,0xf7,0x7f,0xbf,0xdf,0xef,};
- void delay100ms(void) //误差 0us
- {
- unsigned char a,b,c;
- for(c=19;c>0;c--)
- for(b=20;b>0;b--)
- for(a=130;a>0;a--);
- }
- void main()
- {
- while(1)
- {
- unsigned int i;
- for(i=0;i<8;i++)
- {
- LED=table[i];
- delay100ms();
- }
- }
- }
复制代码
|
-
-
走马灯.zip
404 Bytes, 下载次数: 8, 下载积分: 黑币 -5
单片机走马灯程序
|