Turn Indicator

dsc_0668

dsc_06691

dsc_0670

dsc_0673

byte Button = 12;

byte Player1_LED_PIN = 2; // the number of the input pin
byte Player2_LED_PIN = 3; // the number of the input pin
byte Player3_LED_PIN = 4; // the number of the input pin
byte Player4_LED_PIN = 5; // the number of the input pin

//byte Player1_ButtonPin = 12

byte CurrentPlayer = 1;
byte turnorder;

int reading;
int previous = LOW;

void setup()
{

pinMode(Player1_LED_PIN, OUTPUT);
pinMode(Player2_LED_PIN, OUTPUT);
pinMode(Player3_LED_PIN, OUTPUT);
pinMode(Player4_LED_PIN, OUTPUT);

pinMode(Button, INPUT);

Player_LED_ON (CurrentPlayer) ;
}

void loop() {

reading = digitalRead(Button);

if (reading == LOW) {
if (CurrentPlayer < 4) {
CurrentPlayer++;
}
else {
CurrentPlayer = 1;
}

Player_LED_ON (CurrentPlayer);
delay(1000);
} else {
delay(0);
}

}

void Player_LED_ON (int player) {

byte CurrentPlayerLEDPin;

digitalWrite(Player1_LED_PIN, LOW);
digitalWrite(Player2_LED_PIN, LOW);
digitalWrite(Player3_LED_PIN, LOW);
digitalWrite(Player4_LED_PIN, LOW);

switch (player) {
case 1:
CurrentPlayerLEDPin = Player1_LED_PIN;
break;
case 2:
CurrentPlayerLEDPin = Player2_LED_PIN;
break;
case 3:
CurrentPlayerLEDPin = Player3_LED_PIN;
break;
case 4:
CurrentPlayerLEDPin = Player4_LED_PIN;
break;
}

digitalWrite(CurrentPlayerLEDPin, HIGH);
}

/*byte Read_Player_Button (byte player) {

byte CurrentPlayerBUTTONPin;
byte state;

switch (player) {
case 1:
CurrentPlayerBUTTONPin = Button;
break;
case 2:
CurrentPlayerBUTTONPin = Button;
break;
case 3:
CurrentPlayerBUTTONPin = Button;
break;
case 4:
CurrentPlayerBUTTONPin = Button;
break;

}*/

//state = digitalRead(CurrentPlayerBUTTONPin);
//return state;

dsc_0678