Mình đang thắc mắc đoạn code này mình tìm hiểu cả đêm vẫn không hiểu, mong mọi người giúp mình với
#include<at89x52.h>
void MSDelay (unsigned int value);
sbit sense1=P1^0; sbit sense2=P1^1; sbit buz1=P1^4;
sbit buz2=P1^5; sbit led=P2^7; void main ()
{
int i; P1=0xf0; buz1=0; buz2=0; led=0; while (1)
{
if (sense1==1 && sense2!=1)
{ buz1=1; led=1;
for (i=0;i<=2;i++)
{
P2=0x66; MSDelay (10); P2=0xCC;
MSDelay (10); P2=0x99; MSDelay (10);
P2=0x33;
MSDelay (10);
}
}
sense1=0;
if (sense2==1 && sense1!=1)
{ buz1=0; led=0;
for (i=0; i<=2;i++)
{
P2=0x66; MSDelay (10); P2=0x33; MSDelay (10); P2=0x99; MSDelay (10); P2=0xCC; MSDelay (10);
}
for(i=0;i<=2;i++)
{
P0=0x66; MSDelay (10); P0=0xCC; MSDelay (10); P0=0x99; MSDelay (10); P0=0x33;
MSDelay (10);
}
}
sense2=0;
if (sense1==1 && sense2==1)
{
buz2=1;
MSDelay (200);
buz2=0;
}
sense1=0;
sense2=0;
}
}
void MSDelay (unsigned int value)
{
unsigned int x,y; for(x=0; x<1275;x++) for(y=0;y<value;y++);
}
#include<at89x52.h>
void MSDelay (unsigned int value);
sbit sense1=P1^0; sbit sense2=P1^1; sbit buz1=P1^4;
sbit buz2=P1^5; sbit led=P2^7; void main ()
{
int i; P1=0xf0; buz1=0; buz2=0; led=0; while (1)
{
if (sense1==1 && sense2!=1)
{ buz1=1; led=1;
for (i=0;i<=2;i++)
{
P2=0x66; MSDelay (10); P2=0xCC;
MSDelay (10); P2=0x99; MSDelay (10);
P2=0x33;
MSDelay (10);
}
}
sense1=0;
if (sense2==1 && sense1!=1)
{ buz1=0; led=0;
for (i=0; i<=2;i++)
{
P2=0x66; MSDelay (10); P2=0x33; MSDelay (10); P2=0x99; MSDelay (10); P2=0xCC; MSDelay (10);
}
for(i=0;i<=2;i++)
{
P0=0x66; MSDelay (10); P0=0xCC; MSDelay (10); P0=0x99; MSDelay (10); P0=0x33;
MSDelay (10);
}
}
sense2=0;
if (sense1==1 && sense2==1)
{
buz2=1;
MSDelay (200);
buz2=0;
}
sense1=0;
sense2=0;
}
}
void MSDelay (unsigned int value)
{
unsigned int x,y; for(x=0; x<1275;x++) for(y=0;y<value;y++);
}
Comment