// Global variables
int startTheGame = 0;
int theWinnerIs = 0;
int p1PlayingTheGame = 0;
int p2PlayingTheGame = 0;
int P1AtStart = 0;
int P2AtStart = 0;
// Pin assignments for Player 1
const int P1GoHomeLed = 13;
const int P1StartLed = 12;
const int P1WinLed = 11;
const int P1Fail = 10;
const int P1Start = 9;
const int P1End = 8;
// Pin assignments for Player 2
const int P2GoHomeLed = 7;
const int P2StartLed = 6;
const int P2WinLed = 5;
const int P2Fail = 4;
const int P2Start = 3;
const int P2End = 2;
void setup() {
// Set pin modes for LEDs and buttons
pinMode(P1GoHomeLed, OUTPUT);
pinMode(P1StartLed, OUTPUT);
pinMode(P1WinLed, OUTPUT);
pinMode(P1Fail, INPUT_PULLUP);
pinMode(P1Start, INPUT_PULLUP);
pinMode(P1End, INPUT_PULLUP);
pinMode(P2GoHomeLed, OUTPUT);
pinMode(P2StartLed, OUTPUT);
pinMode(P2WinLed, OUTPUT);
pinMode(P2Fail, INPUT_PULLUP);
pinMode(P2Start, INPUT_PULLUP);
pinMode(P2End, INPUT_PULLUP);
// Initialize LED states
digitalWrite(P1StartLed, LOW);
digitalWrite(P1GoHomeLed, HIGH);
digitalWrite(P2StartLed, LOW);
digitalWrite(P2GoHomeLed, HIGH);
}
void loop() {
randomLightShow();
}
void randomLightShow() {
// Randomly flash LEDs for both players
int duration = 250; // Duration of each random flash
for (int i = 0; i < 20; i++) { // Perform 20 random flashes
// Player 1
digitalWrite(P1GoHomeLed, random(2) == 0 ? HIGH : LOW);
digitalWrite(P1StartLed, random(2) == 0 ? HIGH : LOW);
digitalWrite(P1WinLed, random(2) == 0 ? HIGH : LOW);
// Player 2
digitalWrite(P2GoHomeLed, random(2) == 0 ? HIGH : LOW);
digitalWrite(P2StartLed, random(2) == 0 ? HIGH : LOW);
digitalWrite(P2WinLed, random(2) == 0 ? HIGH : LOW);
delay(duration);
}
// Turn off all LEDs after light show
digitalWrite(P1GoHomeLed, LOW);
digitalWrite(P1StartLed, LOW);
digitalWrite(P1WinLed, LOW);
digitalWrite(P2GoHomeLed, LOW);
digitalWrite(P2StartLed, LOW);
digitalWrite(P2WinLed, LOW);
}