Hi everyone. Im very much new to this forum and would really appreciate to have help all around.
Im doing a project with C language to control a radio using a remote control. I generally have 5 buttons on the remote of which 1 of the buttons need to have a single press (mute function) and a long press (turn ON/OFF) as well.
The problem that I am currently facing is that although I've tried to do several ways, such as for loops, while loops, if else etc.. but non works.
It seems that it always goes into the else if loop instead of if and/or else, even though the counter is set at the correct number.[ATTACH]12369Code:void construct(void) { #if 1 //assuming all variables are properly declared in unsigned char { if ((key > 205) && (key < 235)) //button 1 { count++; if ((count > 1) && (count <= 51)) //short press { d1 = 0xXX; d2 = 0xYY; } else if ((count > 51) && (count <=255)) //long press { d1 = 0xXX; d2 = 0xYY; } else { } } else if ((key > 155) && (key < 173)) //button 2 { d1 = 0xXX; d2 = 0xYY; } else if ((key > 80) && (key < 141)) //button 3 { d1 = 0xXX; d2 = 0xYY; } else if ((key > 47) && (key < 78)) //button 4 { d1 = 0xXX; d2 = 0xYY; } else if ((key >= 0) && (key < 15)) //button 5 { d1 = 0xXX; d2 = 0xYY; } else { } } #endif }
Could anyone please help and see if there is anything that I missed?
gumasumnida.