mirror of
https://github.com/deq-boards/microcontroller.git
synced 2025-10-21 18:59:18 +02:00
first microcontroller code
5 potentiometers 14 buttons
This commit is contained in:
parent
436a7b3ad0
commit
3347c29e91
1 changed files with 47 additions and 0 deletions
47
deq-microcontroller.ino
Normal file
47
deq-microcontroller.ino
Normal 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);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue