#include <regx51.h>
#define led P2
#define XUNG P1_0 //LAY XUNG TU 555
unsigned char quay;
unsigned char mode=0xaa;
void delay_555()
{
while(XUNG==1)
{
if(mode==0x55)//?????????????????
{
break;
}
}
while(XUNG==0)
{
if(mode==0x55)//?????????????????
{
break;
}
}
}
//************************
void delay(unsigned int ms)
{
unsigned int i;
unsigned char j;
for(i=0;i<ms;i++)
{
for(j=0;j<125;j++)
{
}
}
}
//********chon xung 555 hay xung noi***********
void int0_ISR (void) interrupt 0 {
mode=~mode;
}
main()
{
EX0=1;
EA=1;
IT0=1;
while(1)
{
led=0x01;
for(quay=0;quay<8;quay++)
{
if(mode==0xaa)
{
delay_555();
}
else
{
delay(300);
}
led<<=1;
}
}
}
#define led P2
#define XUNG P1_0 //LAY XUNG TU 555
unsigned char quay;
unsigned char mode=0xaa;
void delay_555()
{
while(XUNG==1)
{
if(mode==0x55)//?????????????????
{
break;
}
}
while(XUNG==0)
{
if(mode==0x55)//?????????????????
{
break;
}
}
}
//************************
void delay(unsigned int ms)
{
unsigned int i;
unsigned char j;
for(i=0;i<ms;i++)
{
for(j=0;j<125;j++)
{
}
}
}
//********chon xung 555 hay xung noi***********
void int0_ISR (void) interrupt 0 {
mode=~mode;
}
main()
{
EX0=1;
EA=1;
IT0=1;
while(1)
{
led=0x01;
for(quay=0;quay<8;quay++)
{
if(mode==0xaa)
{
delay_555();
}
else
{
delay(300);
}
led<<=1;
}
}
}
Comment