/* 从右往左*/
#include
sbit ADDR0 = P1^0;
sbit ADDR1 = P1^1;
sbit ADDR2 = P1^2;
sbit ADDR3 = P1^3;
sbit ENLED = P1^4;
void main()
{
unsigned int count = 0;
unsigned int cnt = 1;
ADDR0=0;
ADDR1=1;
ADDR2=1;
ADDR3=1;
ENLED=0;
while(1)
{
P0=~(0x01<
for(count=0;count<30000;count++);
cnt++;
if(cnt>=8)
{
cnt=0;
}
}
}
/*来回闪烁*/ 自己编写
#include
sbit ADDR0 = P1^0;
sbit ADDR1 = P1^1;
sbit ADDR2 = P1^2;
sbit ADDR3 = P1^3;
sbit ENLED = P1^4;
void main()
{
unsigned int count = 0;
unsigned int cnt = 0;
unsigned int i=0;
ADDR0=0;
ADDR1=1;
ADDR2=1;
ADDR3=1;
ENLED=0;
for(cnt=0;cnt<8;cnt++)
{
P0=~(0x01<
for(count=0;count<30000;count++);
}
if(cnt>=7)
{
for(i=0;i<8;i++)
{
P0=~(0x80>>i);
for(count=0;count<30000;count++);
}
}
}
/*来回闪烁*/ 参考
#include
sbit ADDR0 = P1^0;
sbit ADDR1 = P1^1;
sbit ADDR2 = P1^2;
sbit ADDR3 = P1^3;
sbit ENLED = P1^4;
void main()
{
unsigned int i=0;
unsigned int j;
unsigned int k=0x01;
ADDR0=0;
ADDR1=1;
ADDR2=1;
ADDR3=1;
ENLED=0;
while(1)
{
P0=~k;
for(j=0;j<30000;j++);
if(i==0)
{
k=k<<1;
if(k==0x80)
i=1;
}
else
{
k=k>>1;
if(k==0x01)
i=0;
}
}
}