zr125
Newbie level 6
How do i remove debounce? it is not a swtich debounce. my source code are as follow.
its about ir sensor, when then sensor is trigger, it sends data thru uart. it supposed to be in sequence, either IR1-->IR2 or IR2-->IR1.
my problem is when sensor trigger, it send bounce data like i want it to send "a" then "b" but instead, it send double or triple "a" then "b". how do i set it to send "a" once only, then "b" and vice versa.
unsigned int IR1,IR2;
void main(){
TRISA = 0xFF;
ADCON1 = 0x00;
TRISD = 0x00;
UART1_Init(9600); // Initialize UART module at 9600 bps
delay_ms(100); // Wait for UART module to stabilize
for(;{
IR1 = Adc_Read(1);
IR2 = Adc_Read(2);
if (IR1<930){
PORTD.F2 = 1;
delay_ms(200);
UART1_Write_Text("a");}
else if (IR2<930){
PORTD.F1 = 1;
delay_ms(200);
UART1_Write_Text("b");}
else {
PORTD = 0x00;
delay_ms(200);}}}
its about ir sensor, when then sensor is trigger, it sends data thru uart. it supposed to be in sequence, either IR1-->IR2 or IR2-->IR1.
my problem is when sensor trigger, it send bounce data like i want it to send "a" then "b" but instead, it send double or triple "a" then "b". how do i set it to send "a" once only, then "b" and vice versa.