Nguyên văn bởi tychuot289
Xem bài viết
#include<At892051.h> // khai bao thu vien cho 89c2051
void delay (int ms) // ham tao tre
{
int i,j;
for(i=0;i<ms;i++)
{
for(j=0;j<125;j++)
{}
}
}
// KHAI BAO MANG
unsigned char
mang2[]={0x7e,0xbd,0xdb,0xe7,0xe7,0xdb,0xbd,0x7e} , // sang chay vao chay ra
mang3[]={0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe,0xfe,0x7 e,0xbe,0xde,0xee,0xf6,0xfa,0xfc,0x7c,
0xbc,0xdc,0xec,0xf4,0xf8,0x78,0xb8,0xd8,0xe8,0xf0, 0x70,
0xb0,0xd0,0xe0,0x60,0xa0,0xc0,0x40,0x80,0};// led sang tang tu chan0->7
void main()
{
int i;
while(1)
{
for(i=0;i<8;i++) // sang ra-vao
{
P1=mang2[i]; delay(300);
}
P1=0xff;delay(500);
for(i=0;i<3;i++) // led chan led-sang tat
{ P1=0xaa;delay(300);
P1=0x55;delay(300);
}
P1=0xff;
delay(200);
for(i=0;i<37;i++) // sang don
{
P1=mang3[i];delay(150);}
} delay(200);
P1=0xff; delay(1500);
}
void delay (int ms) // ham tao tre
{
int i,j;
for(i=0;i<ms;i++)
{
for(j=0;j<125;j++)
{}
}
}
// KHAI BAO MANG
unsigned char
mang2[]={0x7e,0xbd,0xdb,0xe7,0xe7,0xdb,0xbd,0x7e} , // sang chay vao chay ra
mang3[]={0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe,0xfe,0x7 e,0xbe,0xde,0xee,0xf6,0xfa,0xfc,0x7c,
0xbc,0xdc,0xec,0xf4,0xf8,0x78,0xb8,0xd8,0xe8,0xf0, 0x70,
0xb0,0xd0,0xe0,0x60,0xa0,0xc0,0x40,0x80,0};// led sang tang tu chan0->7
void main()
{
int i;
while(1)
{
for(i=0;i<8;i++) // sang ra-vao
{
P1=mang2[i]; delay(300);
}
P1=0xff;delay(500);
for(i=0;i<3;i++) // led chan led-sang tat
{ P1=0xaa;delay(300);
P1=0x55;delay(300);
}
P1=0xff;
delay(200);
for(i=0;i<37;i++) // sang don
{
P1=mang3[i];delay(150);}
} delay(200);
P1=0xff; delay(1500);
}
Comment