|
#include
#include
#define uchar unsigned char
#define uint unsigned int
uchar temp;
uchar tt,idelay,i=0,kk=0,pp=2;
void main()
{
TMOD=0X01;
EA=1;
ET0=1;
TR0=1;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
temp=0xFE;
P0=temp;
while(1)
{
while(1)
{
if(idelay > 0)
{
idelay = 0;
kk++;
if(kk == 8)
{
kk = 0;
pp++;
}
if (pp % 2 == 0) //????????×????????±kk=8???±?ò??pp??1?ó??1?????ú×?????×?else????????
temp = _crol_(temp, 1);
else
temp = _cror_(temp, 1); //?±kk=8???ópp=1,??×?????±????????±????8???ó??pp????1????2??????????????
P0 = temp;
}
}
}
}
void timer0() interrupt 1
{
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
tt++;
if(tt==10)
{ tt=0;
idelay=1;
}
} 具体循环式 0 0 0 0 0 0 0 0(右移)
0 0 0 0 0 0 0 0 (左移)都是对的,但是在最后一次移动到最左的时候,最右边1个灯亮一下, 然后再从左边开始向右移,每次都会发生一次
说明P0口控制流水灯。
|
|