Hi All
I have 10 illuminated push button with LED’s (Button is button and LED is LED).
When I push Button 1 LED 1 needs to turn on HIGH and when im realesing the button LED 1 shall go back to low.
I can get it to Work with 2 buttons but when i am trying with 3 button it goes wrong (and I need it to Work with 10 buttons).
If im using this code:
void setup() {
// put your setup code here, to run once:
pinMode(3, OUTPUT);//This is LED for Button 1
pinMode(5, OUTPUT);//This is LED for Button 2
pinMode(7, OUTPUT);//This is LED for Button 3
pinMode(2, INPUT);//This is Button 1
digitalWrite(2, HIGH);
pinMode(4, INPUT);
digitalWrite(4, HIGH);//This is Button 2
pinMode(6, INPUT);
digitalWrite(6, HIGH);//This is Button 3
}
void loop() {
if (digitalRead(2) == LOW)
{
digitalWrite(3, HIGH);
}
else if (digitalRead(4) == LOW)
{
digitalWrite(5, HIGH);
}
else if (digitalRead(6) == LOW)
{
digitalWrite(7, HIGH);
}
else
{
digitalWrite(3, LOW);
digitalWrite(5, LOW);
digitalWrite(7, LOW);
}
}
Hope someone will help.
Best regard
Soren