Switched to constants for pin numbers

This commit is contained in:
2025-10-22 13:31:22 +02:00
parent 2e6aa58cf9
commit a6b5f93934
2 changed files with 48 additions and 31 deletions

16
include/pinDefinitions.h Normal file
View File

@@ -0,0 +1,16 @@
#pragma once
const int POT_CS = 10;
const int POT_UD = 9;
const int LED_HIGH = 11; // Green
const int LED_MED = 12; // Red
const int LED_LOW = 13; // Green
const int BTN_STAFF_UP = 2;
const int BTN_STAFF_DWN = 4;
const int REMOTE_A = 17;
const int REMOTE_B = 16;
const int REMOTE_C = 15;
const int REMOTE_D = 14;

View File

@@ -1,4 +1,5 @@
#include <Arduino.h> #include <Arduino.h>
#include <pinDefinitions.h>
#include <potControlls.h> #include <potControlls.h>
const int USER_STEPS = 2; const int USER_STEPS = 2;
@@ -17,23 +18,23 @@ bool debounceRead(int buttonPin);
void setup() void setup()
{ {
pinMode(11, OUTPUT); // Green pinMode(LED_HIGH, OUTPUT); // Green
pinMode(12, OUTPUT); // Red LED (D4) pinMode(LED_MED, OUTPUT); // Red LED (D4)
pinMode(LED_BUILTIN, OUTPUT); // Green LED pinMode(LED_LOW, OUTPUT); // Green LED
pinMode(2, INPUT); // SW1 pinMode(BTN_STAFF_UP, INPUT); // SW1
pinMode(4, INPUT); // SW2 pinMode(BTN_STAFF_DWN, INPUT); // SW2
// RF Receiver // RF Receiver
pinMode(A0, INPUT); // Remote Button D pinMode(REMOTE_A, INPUT); // Remote Button A
pinMode(A1, INPUT); // Remote Button C pinMode(REMOTE_B, INPUT); // Remote Button B
pinMode(A2, INPUT); // Remote Button B pinMode(REMOTE_C, INPUT); // Remote Button C
pinMode(A3, INPUT); // Remote Button A pinMode(REMOTE_D, INPUT); // Remote Button D
pinMode(10, OUTPUT); // D10 - CS pinMode(POT_CS, OUTPUT); // D10 - CS
pinMode(9, OUTPUT); // D9 - U/D pinMode(POT_UD, OUTPUT); // D9 - U/D
digitalWrite(10, HIGH); digitalWrite(POT_CS, HIGH);
digitalWrite(9, LOW); digitalWrite(POT_UD, LOW);
for (int i = 0; i < 64; i++) for (int i = 0; i < 64; i++)
{ {
@@ -46,29 +47,29 @@ void loop()
switch (maxVolume) switch (maxVolume)
{ {
case 64: case 64:
digitalWrite(11, HIGH); digitalWrite(LED_HIGH, HIGH);
digitalWrite(12, LOW); digitalWrite(LED_MED, LOW);
digitalWrite(LED_BUILTIN, LOW); digitalWrite(LED_LOW, LOW);
break; break;
case 48: case 48:
digitalWrite(11, LOW); digitalWrite(LED_HIGH, LOW);
digitalWrite(12, HIGH); digitalWrite(LED_MED, HIGH);
digitalWrite(LED_BUILTIN, LOW); digitalWrite(LED_LOW, LOW);
break; break;
case 32: case 32:
digitalWrite(11, LOW); digitalWrite(LED_HIGH, LOW);
digitalWrite(12, LOW); digitalWrite(LED_MED, LOW);
digitalWrite(LED_BUILTIN, HIGH); digitalWrite(LED_LOW, HIGH);
break; break;
case 16: case 16:
digitalWrite(11, HIGH); digitalWrite(LED_HIGH, HIGH);
digitalWrite(12, HIGH); digitalWrite(LED_MED, HIGH);
digitalWrite(LED_BUILTIN, HIGH); digitalWrite(LED_LOW, HIGH);
break; break;
} }
// SW1 - Staff Volume Up // SW1 - Staff Volume Up
if (!debounceRead(2)) if (!debounceRead(BTN_STAFF_UP))
{ {
if (maxVolume < 100) if (maxVolume < 100)
{ {
@@ -77,7 +78,7 @@ void loop()
} }
// SW2 - Staff Volume Down // SW2 - Staff Volume Down
if (!debounceRead(4)) if (!debounceRead(BTN_STAFF_DWN))
{ {
if (maxVolume > STAFF_STEPS) if (maxVolume > STAFF_STEPS)
{ {
@@ -102,7 +103,7 @@ void loop()
} }
// Remote D - Mute // Remote D - Mute
if (debounceRead(A0)) if (debounceRead(REMOTE_D))
{ {
// Check if we are in a muted state // Check if we are in a muted state
@@ -145,7 +146,7 @@ void loop()
} }
// Remote A - Significantly Lower Volume // Remote A - Significantly Lower Volume
if (debounceRead(A3)) if (debounceRead(REMOTE_A))
{ {
// Check if we volume is already lowered // Check if we volume is already lowered
@@ -190,7 +191,7 @@ void loop()
// Remote B - Volume Up // Remote B - Volume Up
// Make sure we are not is a state of mute or lowered // Make sure we are not is a state of mute or lowered
if (debounceRead(A2) && !(oldUserVolume > userVolume)) if (debounceRead(REMOTE_B) && !(oldUserVolume > userVolume))
{ {
if ((userVolume + USER_STEPS) > maxVolume) if ((userVolume + USER_STEPS) > maxVolume)
{ {
@@ -215,7 +216,7 @@ void loop()
} }
// Remote C - Volume Down // Remote C - Volume Down
if (debounceRead(A1) && !(oldUserVolume > userVolume)) if (debounceRead(REMOTE_C) && !(oldUserVolume > userVolume))
{ {
if ((userVolume - USER_STEPS) < 0) if ((userVolume - USER_STEPS) < 0)
{ {