// 51微控制器控制八個發光二極體 左右迴圈。
#include
#define uchar unsigned char
#define uint unsigned int
unsigned char TAB[]= {0xff,0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f,0xff,0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe,0xff}; // 改變這裡 LED 各種花樣
uchar t,i;
void main()
{
TMOD=0x10;
TH1=(65535-50000)/256; // 50ms一次
TL1=(65535-50000)%256;
EA=1;
ET1=1;//開定時器1中斷
TR1=1;//啟動定時器1
t=0;
i=0;
while(1)
}
void timer1() interrupt 3
t++;
if(t==20)
P2=TAB[i];
i++;
if(i==18) { i=0;}
// 51微控制器控制八個發光二極體 左右迴圈。
#include
#define uchar unsigned char
#define uint unsigned int
unsigned char TAB[]= {0xff,0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f,0xff,0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe,0xff}; // 改變這裡 LED 各種花樣
uchar t,i;
void main()
{
TMOD=0x10;
TH1=(65535-50000)/256; // 50ms一次
TL1=(65535-50000)%256;
EA=1;
ET1=1;//開定時器1中斷
TR1=1;//啟動定時器1
t=0;
i=0;
while(1)
{
}
}
void timer1() interrupt 3
{
TH1=(65535-50000)/256; // 50ms一次
TL1=(65535-50000)%256;
t++;
if(t==20)
{
t=0;
P2=TAB[i];
i++;
if(i==18) { i=0;}
}
}