How to add off and on my led & buttons

const int pins[3] = {5,7,9}; //led

void setup(){
for (int i=0; i<3; i++){

pinMode(pins[i], OUTPUT);
}
pinMode(10, INPUT_PULLUP);// b1
pinMode(11, INPUT_PULLUP);// b2
pinMode(12, INPUT_PULLUP);// b3

}

void loop(){

for (int i=0; i<3; i++){

if(digitalRead(pins[i]) == HIGH){

}
if (digitalRead(10) == LOW){ //b1
m = 0;
}
if (digitalRead(11) == LOW){ //b2
m = 1;
}
if (digitalRead(12) == LOW){ //b3
m = 2;
}
switch (m){
case 0: {
digitalWrite(5, HIGH); // led
digitalWrite(7, LOW);
digitalWrite(9, LOW);
delay(1);
break;
}
case 1: {
digitalWrite(7, HIGH);
digitalWrite(5, LOW);
digitalWrite(9, LOW);
delay(1);
break;
}
case 2: {
digitalWrite(9, HIGH);
digitalWrite(7, LOW);
digitalWrite(5, LOW);
delay(1);
break;
}

 }

}

Can you go to your code in your editor, hit CTRL T and then copy paste the code in code tags?
This way it is pretty hard to read.

Also:
What is your code supposed to do?
What does it actually do?
What is the difference?

i want to turn off the led

And what trigger is supposed to turn off the LED?

led only

i have a arduino simulator do you want to check ?

If you do not answer the question I can only suggest to take the plug out. Your LED will turn off then.

okey

if(digitalRead(pins[i]) == HIGH){

}

The } should probably be at the end of the sketch...

Now the if does nothing.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.