- Tue Jun 26, 2018 8:29 am
#199564
Hey guys.
I've used an Arduino pro mini 3.3v together with a set of IR beam break sensors https://www.amazon.co.uk/dp/B0742B8P8W/ ... 4d40b9dc15
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
pinMode(IR_PIN, INPUT); //from IR receiver
}
void loop() {
val = digitalRead(IR_PIN);
digitalWrite(ALARM_PIN, val);
}
I've used an Arduino pro mini 3.3v together with a set of IR beam break sensors https://www.amazon.co.uk/dp/B0742B8P8W/ ... 4d40b9dc15
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
pinMode(IR_PIN, INPUT); //from IR receiver
}
void loop() {
val = digitalRead(IR_PIN);
digitalWrite(ALARM_PIN, val);
}