From 3347c29e9133c0e0647416b2483aa62e91606162 Mon Sep 17 00:00:00 2001 From: Jonas_Jones Date: Fri, 10 Oct 2025 21:06:28 +0200 Subject: [PATCH] first microcontroller code 5 potentiometers 14 buttons --- deq-microcontroller.ino | 47 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 deq-microcontroller.ino diff --git a/deq-microcontroller.ino b/deq-microcontroller.ino new file mode 100644 index 0000000..7b7ee6c --- /dev/null +++ b/deq-microcontroller.ino @@ -0,0 +1,47 @@ +/* + +CODE FOR DEQ WITH: +================= + +- 5 Analogue Potentiometers +- 14 Digital Buttons + +*/ + +// Potentiometer and button pin configuration +const int NUM_POTS = 5; +const int potPins[NUM_POTS] = {A0, A1, A2, A3, A4}; + +const int NUM_BUTTONS = 14; +// D2 to D13 (12 pins), A5 and A6 (as digital pins) +const int buttonPins[NUM_BUTTONS] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, A5, A6}; + +void setup() { + Serial.begin(9600); + + // Set button pins as inputs with internal pull-up resistors + for (int i = 0; i < NUM_BUTTONS; i++) { + pinMode(buttonPins[i], INPUT_PULLUP); + } +} + +void loop() { + // Read and print potentiometer values + Serial.print("POTS: "); + for (int i = 0; i < NUM_POTS; i++) { + int potVal = analogRead(potPins[i]); + Serial.print(potVal); + if (i < NUM_POTS - 1) Serial.print(", "); + } + + Serial.print(" | BUTTONS: "); + // Read and print button states + for (int i = 0; i < NUM_BUTTONS; i++) { + int btnState = digitalRead(buttonPins[i]); + Serial.print(btnState == LOW ? "1" : "0"); + if (i < NUM_BUTTONS - 1) Serial.print(", "); + } + + Serial.println(); + delay(100); +}