Add a small test program for the UNO
authorLukáš Jiřiště <jiriste@icpf.cas.cz>
Tue, 22 Oct 2024 08:28:33 +0000 (10:28 +0200)
committerLukáš Jiřiště <jiriste@icpf.cas.cz>
Tue, 22 Oct 2024 08:28:33 +0000 (10:28 +0200)
This program makes a LED (pin 4) switch state whenever pin 7 is
connected to ground (through button).

Servomatic.ino [new file with mode: 0644]

diff --git a/Servomatic.ino b/Servomatic.ino
new file mode 100644 (file)
index 0000000..684a35c
--- /dev/null
@@ -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);
+}