// https://forum.arduino.cc/t/mechanical-pinball-to-mlb-scoreboard/1216304/
// https://andyspinballgames.com/wp-content/uploads/2020/03/Williams-Pitch-Bat-backglass-scaled.jpg
// https://i.imgur.com/JgFH9cj.jpeg
/*
LIGHTS
Player 1 (1 light)
Player 2 (1 light)
inning (9 lights)
current outs (3 light)
current balls (4 lights)
current strikesj (3 lights)
BUTTONS
Single (2)
Double (2)
Triple (1)
Home run (1)
Out (3)
ROTARY
Runners (4 bases)
Home Score (two rotary 0 - 9)
Away Score (two rotary 0 - 9)
*/
const int numRelays = 16; // Number of relays
const int relayPins[numRelays] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, A0, A1, A2, A3}; // Define relay pins
void setup() {
// Set all relay pins as OUTPUT
for (int i = 0; i < numRelays; i++) {
pinMode(relayPins[i], OUTPUT);
digitalWrite(relayPins[i], LOW); // Ensure all relays are initially off
}
Serial.begin(9600); // Initialize serial communication
Serial.println("Enter the number of times to close each relay:");
}
void loop() {
// Relay 1
Serial.println("Enter the number of times to close relay 1:");
while (Serial.available() == 0) {}
int numClosures1 = Serial.parseInt();
closeRelay(0, numClosures1); // Close relay 1
/* // Relay 2
Serial.println("Enter the number of times to close relay 2:");
while (Serial.available() == 0) {}
int numClosures2 = Serial.parseInt();
closeRelay(1, numClosures2); // Close relay 2
// Relay 3
Serial.println("Enter the number of times to close relay 3:");
while (Serial.available() == 0) {}
int numClosures3 = Serial.parseInt();
closeRelay(2, numClosures3); // Close relay 3
*/
// Add similar blocks for remaining relays...
}
// Function to close a relay
void closeRelay(int relayIndex, int numClosures) {
if (numClosures > 0) {
for (int j = 0; j < numClosures; j++) {
digitalWrite(relayPins[relayIndex], HIGH);
delay(500); // Adjust delay as needed (milliseconds)
digitalWrite(relayPins[relayIndex], LOW);
delay(500); // Adjust delay as needed (milliseconds)
}
Serial.print("Relay ");
Serial.print(relayIndex + 1);
Serial.println(" closed.");
} else {
Serial.print("Invalid input for relay ");
Serial.print(relayIndex + 1);
Serial.println(". Please enter a positive number.");
}
}