int a = 3;
int b=13;
unsigned char IRCOM[7];
void jiema();
void setup()
{Serial.begin(9600);
pinMode(3,INPUT);
pinMode(b,OUTPUT);
}void loop()
{
while(1)
{
jiema();
if(IRCOM[2]==0x80)
digitalWrite(13,1);
else digitalWrite(13,0);
Serial.println(IRCOM[2],HEX);
}}
void jiema()
{
unsigned char j,k,N=0;
while (!digitalRead(3));
while (digitalRead(3));
for (j=0;j<4;j++)
{
for (k=0;k<8;k++)
{
while (!digitalRead(3));
while (digitalRead(3))
{
delayMicroseconds(127);
N++;
if (N>=30)
{
return;
}
}
IRCOM[j]=IRCOM[j] >> 1;
if (N>=8) {IRCOM[j] = IRCOM[j]| 0x80;;}
N=0;
}
}
if (IRCOM[2]!=~IRCOM[3])
{
return; }
}
|