From da152247ac936d3d1947c96018c9f0f08732720f Mon Sep 17 00:00:00 2001 From: Philipp Matthias Schaefer Date: Sun, 2 Feb 2020 20:48:18 +0100 Subject: [PATCH] Move space_status update to own function --- arduino/door_status.ino | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/arduino/door_status.ino b/arduino/door_status.ino index 0cfc237..a3a0963 100644 --- a/arduino/door_status.ino +++ b/arduino/door_status.ino @@ -31,9 +31,7 @@ void print_status() { Serial.println(space_status); } -void loop(){ - print_status(); - +void update_space_status() { int pin_status = 0; pin_status = digitalRead(REED_SWITCH_INPUT_PIN); @@ -48,6 +46,12 @@ void loop(){ space_status += 1; } } +} + +void loop(){ + print_status(); + + update_space_status(); // status check if we can switch the status. // low pass prevents waggling a bit