mariocaptain
Member
Hi all,
I have been trying to use 2 difference kind of IR sensors with Teensy (3.2 and 3.5) ISR to no avail as it bounces a lot. One IR sensor is in a coin acceptor which I have tested and is working fine with Arduino. The other kind is a general obstacle avoidance IR sensor, newly bought; I have 2 units and have tested them both with Arduino. I can't seem to make them work with Teensy ISR.
As these sensors are not mechanical, I suppose they should not bounce when trigger.
This is my code:
The problem is "infrared" got triggered like hundreds of times each time the IR sensor detect an obstacle.
Interestingly, this same code works fine on an Arduino UNO or Mega.
Could anyone tell me what I missed?
P.S. I would not like to have to implement some debouncing workaround, because I will have to use many of these in my project, and would not like to disable interrupts for debouncing.
Thanks in advance.
Dave
I have been trying to use 2 difference kind of IR sensors with Teensy (3.2 and 3.5) ISR to no avail as it bounces a lot. One IR sensor is in a coin acceptor which I have tested and is working fine with Arduino. The other kind is a general obstacle avoidance IR sensor, newly bought; I have 2 units and have tested them both with Arduino. I can't seem to make them work with Teensy ISR.
As these sensors are not mechanical, I suppose they should not bounce when trigger.
This is my code:
Code:
volatile int count = 0;
void setup() {
// initialize the digital pin as an output.
pinMode(14, INPUT);
Serial.begin(9600);
attachInterrupt(14, infrared, RISING);
}
// the loop routine runs over and over again forever:
void loop() {
Serial.print("count = ");
Serial.println(count);
delay(500);
}
void infrared()
{
count++;
}
The problem is "infrared" got triggered like hundreds of times each time the IR sensor detect an obstacle.
Interestingly, this same code works fine on an Arduino UNO or Mega.
Could anyone tell me what I missed?
P.S. I would not like to have to implement some debouncing workaround, because I will have to use many of these in my project, and would not like to disable interrupts for debouncing.
Thanks in advance.
Dave