first microcontroller code

5 potentiometers
14 buttons
This commit is contained in:
Jonas_Jones 2025-10-10 21:06:28 +02:00
parent 436a7b3ad0
commit 3347c29e91

47
deq-microcontroller.ino Normal file
View file

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