Garage: new pin for moisture sensor

Doorbell: Vibration motor connected via PC817C optocoupler
This commit is contained in:
2024-05-24 16:17:03 +02:00
parent 4b1502b460
commit 25be0a87fc
4 changed files with 13 additions and 13 deletions
@@ -1,35 +1,31 @@
/* Klingel-Sensor auf Arduino Nano ATmega168
*
* https://www.arduino.cc/en/Tutorial/BuiltInExamples/Button
* https://elektro.turanis.de/html/prj035/index.html
*
* D2 -------------
* | |
* 10kOhm |
* | |
* +5V ----- |
* Button
* |
* GND -------------
* https://docs.arduino.cc/tutorials/generic/digital-input-pullup/
*/
const int ledPin = LED_BUILTIN;
const int buttonPin = 2; // Button connected to D2
const int flare_threshold = 200;
const int ring_delay = 250;
bool active = false;
void setup() {
pinMode(ledPin, OUTPUT);
pinMode(buttonPin, INPUT);
pinMode(buttonPin, INPUT_PULLUP);
Serial.begin(9600);
Serial.println("Doorbell sensor");
}
void loop() {
int val = digitalRead(buttonPin);
if (val == LOW) {
delay(flare_threshold); // catch flares
val = digitalRead(buttonPin);
@@ -45,8 +41,10 @@ void loop() {
Serial.print(flare_threshold);
Serial.println(")");
}
} else {
}
else {
digitalWrite(ledPin, LOW);
active = false;
}
}