đây là lần đầu tiên viết code các bác xem giúp em xem nó sai chỗ nào ạ
#include <REGX52.H>
unsigned int i,j,k;
void delay(unsigned int ms)
{
unsigned int a;
unsigned char b;
for(a=0; a<ms; a++)
{
for(b=0; b<125; b++)
{
}
}
}
void hieu_ung_1 (void)
{
for(k=0; k<8; k++)
{
P0=P1=P2=P3=1;
delay(300);
P0=P1=P2=P3=0;
delay(300);
}
}
void hieu_ung_2 (void)
{
for(i=0; i<6; i++)
{
P0=P1=P2=P3=0;
delay(300);
P0=P1=P2=P3=1;
delay(300);
}
}
void hieu_ung_3 (void)
{
for(j=0; j<8; j++)
{
P0=P1=P2=P3=0xfe;
delay(300);
P0=P1=P2=P3=0x55;
}
}
main()
{
while(1)
{
hieu_ung_1;
delay(300);
hieu_ung_2;
delay(300);
hieu_ung_3;
delay(300);
}
}
#include <REGX52.H>
unsigned int i,j,k;
void delay(unsigned int ms)
{
unsigned int a;
unsigned char b;
for(a=0; a<ms; a++)
{
for(b=0; b<125; b++)
{
}
}
}
void hieu_ung_1 (void)
{
for(k=0; k<8; k++)
{
P0=P1=P2=P3=1;
delay(300);
P0=P1=P2=P3=0;
delay(300);
}
}
void hieu_ung_2 (void)
{
for(i=0; i<6; i++)
{
P0=P1=P2=P3=0;
delay(300);
P0=P1=P2=P3=1;
delay(300);
}
}
void hieu_ung_3 (void)
{
for(j=0; j<8; j++)
{
P0=P1=P2=P3=0xfe;
delay(300);
P0=P1=P2=P3=0x55;
}
}
main()
{
while(1)
{
hieu_ung_1;
delay(300);
hieu_ung_2;
delay(300);
hieu_ung_3;
delay(300);
}
}
Comment