#include
#define LED P1 //宏定義,使用LED代替P1口(相當於LED=P1)
#define uchar unsigned char //用uchar代替unsigned char方便操作
#define uint unsigned int
/*------------------time ms延時函式-----------------*/
void delay_ms(uint time)
{
uchar tres;
for(;time>0;time--)
tres=150;
while(tres--);
}
void main()
uchar t;
LED=0X01;//P1=00000001B
while(1)//死迴圈,不停的點亮和熄滅LED
for(t=0;t
LED=~LED;//按位取反,點亮一個LED
delay_ms(100);//延時0.1s
LED=~LED;//按位取反
LED
LED=0X80;//P1=10000000B
LED>>=1;//右移一位,點亮不同的LED
#include
#define LED P1 //宏定義,使用LED代替P1口(相當於LED=P1)
#define uchar unsigned char //用uchar代替unsigned char方便操作
#define uint unsigned int
/*------------------time ms延時函式-----------------*/
void delay_ms(uint time)
{
uchar tres;
for(;time>0;time--)
{
tres=150;
while(tres--);
}
}
void main()
{
uchar t;
LED=0X01;//P1=00000001B
while(1)//死迴圈,不停的點亮和熄滅LED
{
for(t=0;t
{
LED=~LED;//按位取反,點亮一個LED
delay_ms(100);//延時0.1s
LED=~LED;//按位取反
LED
}
LED=0X80;//P1=10000000B
for(t=0;t
{
LED=~LED;//按位取反,點亮一個LED
delay_ms(100);//延時0.1s
LED=~LED;//按位取反
LED>>=1;//右移一位,點亮不同的LED
}
LED=0X01;//P1=00000001B
}
}