标题:
基于51单片机的流水灯
[打印本页]
作者:
59595959
时间:
2020-12-9 17:19
标题:
基于51单片机的流水灯
#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
unsigned char TAB[]= {0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f}; // 改变这dao里 LED 各种花样du
uchar t,i;
void main()
{
TMOD=0x10;
TH1=(65535-50000)/256; // 50ms一次zhi
TL1=(65535-50000)%256;
EA=1;
ET1=1;//开定时器dao1中断
TR1=1;//启动定时器1
t=0;
i=1;
P2=TAB[0];
while(1)
{
if(t==20)
{
t=0;
P2=TAB[i];
i++;
if(i==8)
{ i=0;}
}
}
}
void timer1() interrupt 3
{
TH1=(65535-50000)/256; // 50ms一次
TL1=(65535-50000)%256;
t++;
}
复制代码
以前的小东西
欢迎光临 (http://www.51hei.com/bbs/)
Powered by Discuz! X3.1