PLEASE HELP ME

I’m doing a project about toggle 3 leds with 3 buttons and my code is error. I don’t know why my code is error. Thankyou

on_off_LED.ino (1.54 KB)

Please post the error message that you get.

...R

Please post your code too.

int pinButton = 5;
int pinButton = 6;
int pinButton = 8;

3 variables with the same name?

Then this

int LED2 = 2;
int LED4 = 4;
int LED7 = 7;

  pinMode(LED1, OUTPUT);
  pinMode(LED2, OUTPUT);
  pinMode(LED3, OUTPUT);

and

int stateButton5;
int stateButton6;
int stateButton8;

  stateButton = digitalRead(pinButton5);  
  stateButton = digitalRead(pinButton6); 
  stateButton = digitalRead(pinButton8);

and

  previous == stateButton5;
  previous == stateButton6;
  previous == stateButton8;

Just wondering, how many Examples from the IDE have you tried out?
Do you know that each has a page on the Arduino site with explanations of the code and wiring?

We can snigger - but OP, you will too in a few weeks, once you understand the language and syntax of the commands!

EDIT: Added OP's original code listing - as [u]CODE[/u] !

/* sketch 3 
turn on a LED when the button is pressed and let it on 
until the button is pressed again
*/
int pinButton = 5;
int pinButton = 6;
int pinButton = 8;
int LED2 = 2;
int LED4 = 4;
int LED7 = 7;
int stateLED2 = LOW;
int stateLED4 = LOW;
int stateLED7 = LOW;
int stateButton5;
int stateButton6;
int stateButton8;
int previous5 = LOW;
int previous6 = LOW;
int previous8 = LOW;
long time = 0;
long debounce = 200;

void setup() {
  pinMode(pinButton5, INPUT);
  pinMode(pinButton6, INPUT);
  pinMode(pinButton8, INPUT);
  pinMode(LED1, OUTPUT);
  pinMode(LED2, OUTPUT);
  pinMode(LED3, OUTPUT);
}

void loop() {
  stateButton = digitalRead(pinButton5);  
  stateButton = digitalRead(pinButton6); 
  stateButton = digitalRead(pinButton8); 

//LED 2
  if(stateButton5 == HIGH && previous5 == LOW && millis() - time > debounce) {
    if(stateLED2 == HIGH){
      stateLED2 = LOW; 
    } else {
       stateLED2 = HIGH; 
    }
       time = millis();
  }
// LED 4
if(stateButton6 == HIGH && previous6 == LOW && millis() - time > debounce) {
    if(stateLED4 == HIGH){
      stateLED4 = LOW; 
    } else {
       stateLED4 = HIGH; 
    }
       time = millis();
  }

// LED 7
if(stateButton8 == HIGH && previous8 == LOW && millis() - time > debounce) {
    if(stateLED7 == HIGH){
      stateLED7 = LOW; 
    } else {
       stateLED7 = HIGH; 
    }
       time = millis();
  }
    
  digitalWrite(LED2, stateLED2);
  digitalWrite(LED4, stateLED4);
  digitalWrite(LED7, stateLED7);
  previous == stateButton5;
  previous == stateButton6;
  previous == stateButton8;
}

I'm not laughing. I just want to raise the OP's awareness enough to get truly started on a clearer path. It takes some digging in the Arduino site to find the information needed even with the library at your fingertips.