Problems with long pressing of infrared remote control[Copy link]
I am using ATMEGA8a. There is no problem with single key press. But I have been working on the continuous code for several days but still can't figure out how to identify the continuous code. Could you please tell me how to identify the continuous code?
uchar IR_buf[4]={0x00,0x00,0x00,0x00}; //IR_buf[0], IR_buf[1] are the user code low and user code high receiving buffers
// IR_buf[2], IR_buf[3] are the key data code and key data code inverse receiving buffers
/********us delay program, delay time 0.14ms(140us*)*******/
{="" uchar="" i,j,sum="0;" gicr="" |="(0<= 30) //If the high level time is too long, exit the processing program
{
GICR |=(1<="" ir_buf="IR_buf" return;="" }="">> 1; //Accept one bit of data
if(sum >= 6)
{IR_buf = IR_buf | 0x80;} //If the count value is greater than 6 (high level time is greater than 0.56), it is data 1
sum = 0; //If the count value is less than 6, the highest bit of the data is filled with "0", indicating that "0" is received, and the timing is cleared at the same time
}
}
if(IR_buf[2]!=~IR_buf[3]) //Invert the key data code and compare it with the key data code. If they are not equal, it means that the received data is wrong and give up