commit 891a5cf982741d14fe8bc55806bc2afcfe8a2eb5
parent 6a6e7907c0fae44e8aa2514cb01dfeda5c5de3d6
Author: prenev <an2qzavok@gmail.com>
Date: Sun, 12 Sep 2021 01:00:12 +0300
add example arduino firmware
Diffstat:
1 file changed, 36 insertions(+), 0 deletions(-)
diff --git a/analog_001.ino b/analog_001.ino
@@ -0,0 +1,36 @@
+int knobs[6], oldknobs[6];
+int pins[6] = {A0, A1, A2, A3, A4, A5};
+
+void
+setknobs(void) {
+ int i;
+ for (i = 0; i < 6; i++)
+ knobs[i] = analogRead(pins[i])>>3;
+}
+
+void
+setoldknobs(void) {
+ int i;
+ for (i = 0; i < 6; i++) oldknobs[i] = knobs[i];
+}
+
+void setup() {
+ setknobs();
+ Serial.begin(115200);
+}
+
+void loop() {
+ int i;
+ char msg[3];
+ char buf[1024];
+ setoldknobs();
+ setknobs();
+ for (i = 0; i < 6; i++) {
+ if (oldknobs[i] != knobs[i]) {
+ msg[0] = 0xB0;
+ msg[1] = i;
+ msg[2] = knobs[i];
+ Serial.write(msg, 3);
+ }
+ }
+}