Code KeilC :
#include<regx52.h>
sbit LED1 = P0^5;
sbit LED2 = P0^6;
sbit LED3 = P0^7;
void delay_ms(unsigned int t);
void main()
{
LED1=LED2=LED3=0xFF; // tat het cac led
delay_ms(1000);
while(1)
{
LED1=0x00; // sang led 1
delay_ms(1000); //delay 1 giay
LED2=0x00; // sang led 2
delay_ms(1000);
LED3=0x00; // sang led 3
delay_ms(1000);
break; // thoat khoi vong lap while
}
}
// chuong trinh con tao delay ms
void delay_ms(unsigned int t )
{
unsigned int x,y;
for(x=0;x<t;x++)
{
for(y=0;y<123;y++); // vong for rong
}
}
0 nhận xét:
Đăng nhận xét