From 01ddb549d68e6f79d85298c3d88e9cab8664e499 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Luk=C3=A1=C5=A1=20Ji=C5=99i=C5=A1t=C4=9B?= Date: Tue, 22 Oct 2024 10:28:33 +0200 Subject: [PATCH] Add a small test program for the UNO This program makes a LED (pin 4) switch state whenever pin 7 is connected to ground (through button). --- Servomatic.ino | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 Servomatic.ino diff --git a/Servomatic.ino b/Servomatic.ino new file mode 100644 index 0000000..684a35c --- /dev/null +++ b/Servomatic.ino @@ -0,0 +1,29 @@ +void wait_for_button(int trigger) +{ + int read_val; + + read_val = digitalRead(7); + while (read_val != trigger) + { + read_val = digitalRead(7); + delay(10); + } +} + +int main() +{ + init(); + pinMode(7, INPUT_PULLUP); + pinMode(4, OUTPUT); + digitalWrite(4, LOW); + while (1) + { + wait_for_button(LOW); + digitalWrite(4, HIGH); + wait_for_button(HIGH); + wait_for_button(LOW); + digitalWrite(4, LOW); + wait_for_button(HIGH); + } + return (0); +} -- 2.30.2