Hello again!
Currently working on a project where when a door is opened a beeper is turned on. I use a door sensor for this.
I attach the code below. The problem about it is that when i close the door the beeper stops beeping.
Any ideas on how i can make the beeper continue to beep for example 30 minutes and then it stops by itself
#include <JC_Button.h>
// pin assignments
const byte DOORSENSOR_PIN(2); //
const byte RELAY_PIN(3); //
Button myBtn(DOORSENSOR_PIN);
const unsigned long LONG_PRESS(300); //
void setup() {
myBtn.begin();
pinMode(RELAY_PIN, OUTPUT);
}
void loop() {
digitalWrite(RELAY_PIN, LOW);
myBtn.read();
if (myBtn.pressedFor(LONG_PRESS)) {
digitalWrite(RELAY_PIN, HIGH);
delay(100);
}
}