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); +}