int Switch1= 12;
int Switch2= 11;
int Switch3= 10;
int RedPIN = 6;
int GreenPIN = 4;
int YellowPIN = 2;
void setup() {
Serial.begin(9600);
pinMode(Switch1, INPUT_PULLUP);
pinMode(Switch2, INPUT_PULLUP);
pinMode(Switch3, INPUT_PULLUP);
pinMode(RedPIN , OUTPUT);
pinMode(GreenPIN , OUTPUT);
pinMode(YellowPIN , OUTPUT);
}
void loop()
{
int SW1 = digitalRead(Switch1);
int SW2 = digitalRead(Switch2);
int SW3 = digitalRead(Switch3);
digitalWrite(RedPIN, LOW);
digitalWrite(GreenPIN, LOW);
digitalWrite(YellowPIN, LOW);
if(SW1 == LOW){
Serial.print("Switch : ");
Serial.println("RED");
digitalWrite(RedPIN, HIGH);
delay(100);
}
if(SW2 == LOW){
Serial.print("Switch : ");
Serial.println("GREEN");
digitalWrite(GreenPIN, HIGH);
delay(100);
}
if(SW3 == LOW){
Serial.print("Switch : ");
Serial.println("YELLOW");
digitalWrite(YellowPIN, HIGH);
delay(100);
}
}