From: Lukáš Jiřiště Date: Tue, 22 Oct 2024 08:28:33 +0000 (+0200) Subject: Add a small test program for the UNO X-Git-Url: https://git.ljiriste.work/?a=commitdiff_plain;h=01ddb549d68e6f79d85298c3d88e9cab8664e499;p=Servomatic.git 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). --- 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); +}