I want to have the Arduino turn a pin HIGH whenever the beam has been broken for 10 secs or more. I’m going to use it as an indicator for trucks waiting in a queue. Therefore it must NOT trigger the alarm if something just passes through the beam.
I’m not quiet sure if I should use a for loop or just a set of delays to manage this
So far I’ve managed to turn the alarm pin HIGH whenever the beam breaks.
Can you guys give some inputs as to how you would make the alarm only trigger after a 10 sec beam break?
My code looks like this:
#define IR_PIN 6
#define LED_PIN 13
#define ALARM_PIN 10
int val = 0;
void setup() {
Serial.begin(19200); //for debug
pinMode(ALARM_PIN, OUTPUT); //Alarm pin
pinMode(LED_PIN, OUTPUT); //setup the pin to light when set
Actually it’s wired so that when the beam breaks the input pin on the arduino goes high.
I’ll just switch that around.
What happens in your code when the count reaches 0? The ALARM_PIN will go high but will the counter reset to 100 automatically when the beam reestablishes?
I’ve only tested the sensors inside over a distance of a few metres. I’m hoping for success outside over 20m. If not I’ll have a whole other problem