From 7d31db7fcbdaf886ce4b4986cbbfa2ed56a92c74 Mon Sep 17 00:00:00 2001 From: Lyubomir Penev Date: Sun, 2 Nov 2025 14:15:46 +0100 Subject: [PATCH] Added function to set pin modes --- include/commonFunctions.h | 6 ++++++ src/commonFunctions.cpp | 26 ++++++++++++++++++++++++++ src/main.cpp | 19 +------------------ 3 files changed, 33 insertions(+), 18 deletions(-) diff --git a/include/commonFunctions.h b/include/commonFunctions.h index 55c6527..33fa502 100644 --- a/include/commonFunctions.h +++ b/include/commonFunctions.h @@ -17,3 +17,9 @@ bool debounceReadNO(int buttonPin); * @return false */ bool debounceReadNC(int buttonPin); + +/** + * @brief Sets all the pins to their correct modes + * + */ +void setPinModes(); \ No newline at end of file diff --git a/src/commonFunctions.cpp b/src/commonFunctions.cpp index 0392a7c..9260f7b 100644 --- a/src/commonFunctions.cpp +++ b/src/commonFunctions.cpp @@ -98,4 +98,30 @@ bool debounceReadNC(int buttonPin) lastButtonStateNC = reading; } return buttonPressed; +} + +/** + * @brief Sets all the pins to their correct modes + * + */ +void setPinModes() +{ + pinMode(LED_HIGH, OUTPUT); // Green + pinMode(LED_MED, OUTPUT); // Red LED (D4) + pinMode(LED_LOW, OUTPUT); // Green LED + + pinMode(BTN_STAFF_UP, INPUT); // SW1 + pinMode(BTN_STAFF_DWN, INPUT); // SW2 + + // RF Receiver + pinMode(REMOTE_A, INPUT); // Remote Button A + pinMode(REMOTE_B, INPUT); // Remote Button B + pinMode(REMOTE_C, INPUT); // Remote Button C + pinMode(REMOTE_D, INPUT); // Remote Button D + + // Potentiometer + pinMode(POT_CS, OUTPUT); // D10 - CS + pinMode(POT_UD, OUTPUT); // D9 - U/D + digitalWrite(POT_CS, HIGH); + digitalWrite(POT_UD, LOW); } \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 7d70740..dae6e56 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -12,24 +12,7 @@ int oldUserVolume = userVolume; void setup() { - pinMode(LED_HIGH, OUTPUT); // Green - pinMode(LED_MED, OUTPUT); // Red LED (D4) - pinMode(LED_LOW, OUTPUT); // Green LED - - pinMode(BTN_STAFF_UP, INPUT); // SW1 - pinMode(BTN_STAFF_DWN, INPUT); // SW2 - - // RF Receiver - pinMode(REMOTE_A, INPUT); // Remote Button A - pinMode(REMOTE_B, INPUT); // Remote Button B - pinMode(REMOTE_C, INPUT); // Remote Button C - pinMode(REMOTE_D, INPUT); // Remote Button D - - // Potentiometer - pinMode(POT_CS, OUTPUT); // D10 - CS - pinMode(POT_UD, OUTPUT); // D9 - U/D - digitalWrite(POT_CS, HIGH); - digitalWrite(POT_UD, LOW); + setPinModes(); // Reset the potentiometer for (int i = 0; i < 64; i++)