Nguyên văn bởi lee_trieu
Xem bài viết
#include <AT89X51.H>
//khai bao thu vien
#define bat 1
#define tat 0
unsigned int i;
//khai bao bien toan cuc
sbit led1=P1^0;
sbit led2=P1^1;
sbit led3=P1^2;
sbit led4=P1^3;
sbit led5=P1^4;
sbit led6=P1^5;
sbit led7=P1^6;
sbit led8=P1^7;
//tao ham delay
void delay(long time)
{
long n;
for(n=0;n<time;n++)
{
;
}
}
void main()
{
while(1)// Lap vo han
{
for(i=1;i<=7;i++)
{
P1=tat;
led1=bat;
delay(1000);
led1=tat;
delay(1000);
led2=bat;
delay(1000);
led2=tat;
delay(1000);
led3=bat;
delay(1000);
led3=tat;
delay(1000);
led4=bat;
delay(1000);
led4=tat;
delay(1000);
led5=bat;
delay(1000);
led5=tat;
delay(1000);
led6=bat;
delay(1000);
led6=tat;
delay(1000);
led7=bat;
delay(1000);
led7=tat;
delay(1000);
led8=bat;
delay(1000);
led8=tat;
delay(1000);
}
}
}
Comment