Umstellung auf externen Pullup-Widerstand

This commit is contained in:
2024-04-22 19:08:58 +02:00
parent 7db58c54f4
commit 4b1502b460
@@ -1,13 +1,14 @@
/* Klingel-Sensor auf Arduino Nano ATmega168 /* Klingel-Sensor auf Arduino Nano ATmega168
* *
* https://www.arduino.cc/en/Tutorial/BuiltInExamples/Button * https://www.arduino.cc/en/Tutorial/BuiltInExamples/Button
* https://elektro.turanis.de/html/prj035/index.html
* *
* D2 ------------- * D2 -------------
* | | * | |
* Button | * 10kOhm |
* | | * | |
* +5V ----- | * +5V ----- |
* 10kOhm * Button
* | * |
* GND ------------- * GND -------------
*/ */
@@ -29,17 +30,17 @@ void setup() {
void loop() { void loop() {
int val = digitalRead(buttonPin); int val = digitalRead(buttonPin);
if (val == HIGH) { if (val == LOW) {
delay(flare_threshold); // catch flares delay(flare_threshold); // catch flares
val = digitalRead(buttonPin); val = digitalRead(buttonPin);
if (val == HIGH && active == false) { if (val == LOW && active == false) {
Serial.println("RING"); Serial.println("RING");
digitalWrite(ledPin, HIGH); digitalWrite(ledPin, HIGH);
active = true; active = true;
delay(ring_delay); delay(ring_delay);
} }
else if (val == LOW) { else if (val == HIGH) {
Serial.print("flare (<"); Serial.print("flare (<");
Serial.print(flare_threshold); Serial.print(flare_threshold);
Serial.println(")"); Serial.println(")");