mấy a sư hunh chỉ dùm e làm thế nào quét led chạy từ chân P0.0 đến p3.7 ạ. đây là code của e
#include <regx51.h>
#define led P2
#define XUNG P1_0 //LAY XUNG TU 555
unsigned char quay;
unsigned char x;
unsigned char m=0x55;
void delay_555()
{
while(XUNG==1)
{
if(m==0xaa)//?????????????????
{
break;
}
}
while(XUNG==0)
{
if(m==0xaa)//?????????????????
{
break;
}
}
}
//************************
void delay(unsigned int ms)
{
unsigned int i;
unsigned char j;
for(i=0;i<ms;i++)
{
for(j=0;j<125;j++)
{
}
}
}
//******************************
void chon_xung()
{
if(m==0x55)
{
delay_555();
}
else
{
delay(300);
}
}
/////////////////**********mang*************//////////
unsigned char code a2[]={0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x01,0x02,0x0 4,0x08,0x10,0x20,0x40,0x80,
0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01};
//********chon xung 555 hay xung noi***********
void int0_ISR
(void) interrupt 0
{
m=~m;
}
main()
{
EX0=1;
EA=1;
IT0=1;
while(1)
{
for(x=0;x<23;x++)
{
led=a2[x];
{
chon_xung();
}
}
}
}
#include <regx51.h>
#define led P2
#define XUNG P1_0 //LAY XUNG TU 555
unsigned char quay;
unsigned char x;
unsigned char m=0x55;
void delay_555()
{
while(XUNG==1)
{
if(m==0xaa)//?????????????????
{
break;
}
}
while(XUNG==0)
{
if(m==0xaa)//?????????????????
{
break;
}
}
}
//************************
void delay(unsigned int ms)
{
unsigned int i;
unsigned char j;
for(i=0;i<ms;i++)
{
for(j=0;j<125;j++)
{
}
}
}
//******************************
void chon_xung()
{
if(m==0x55)
{
delay_555();
}
else
{
delay(300);
}
}
/////////////////**********mang*************//////////
unsigned char code a2[]={0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x01,0x02,0x0 4,0x08,0x10,0x20,0x40,0x80,
0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01};
//********chon xung 555 hay xung noi***********
void int0_ISR
(void) interrupt 0
{
m=~m;
}
main()
{
EX0=1;
EA=1;
IT0=1;
while(1)
{
for(x=0;x<23;x++)
{
led=a2[x];
{
chon_xung();
}
}
}
}
Comment