Simple LED control program

I'm making a project where if one LED gets low another LED goes HIGH automatically, I'm using this if statement, but the error (lvalue required as left operand of assignment) appears.

#define led 13
#define led2 12
#define led3 11





void setup() {
  Serial.begin (9600);
  pinMode(led, OUTPUT);
  pinMode(led2, INPUT);
  pinMode(led3,OUTPUT);
  

}

void loop() {
   if (led2 = HIGH) {
    digitalWrite(led3, HIGH);
   
   } 
  else {
    digitalWrite(led3,LOW);
  }
}

Anyone know how I can make this project run?

if (led2 = HIGH) {

Use ==

CrossRoads: if (led2 = HIGH) {

Use ==

Thanks you sir, I managed to upload it but the program I made can't make the event I wanted. I set pin 13 as an output pin (where an LED is lit up) and the pin 13 output is set as input pin (pin 12). And the light in pin 11 should depend on the input in pin 12. So if pin 13 goes off, pin 11 goes on.

Sorry, I'm noob in programming :/

You never do a digitalWrite to 'led' to make it turn on or off.

define led 13

define led2 12

define led3 11

IMO, get into the habit of using this construct instead.

const byte led = 13; const byte led2 = 12; const byte led3 = 11;

So I got this new code, but still won't make it work

Do I have to follow some codes used it making a switch? Do I need I pull up resistor for the input pin?

#define led 13
#define input1 12
#define led3 11
#define led4 10
#define led5 9
#define led6 8





void setup() {
  Serial.begin (9600);
  pinMode(led, OUTPUT);
  pinMode(input1, INPUT);
  pinMode(led3,OUTPUT);

}

void loop() {
  
   digitalWrite(led, HIGH);
   digitalRead(input1);
   if (input1 == LOW) {
    digitalWrite(led3, HIGH);
   
   } 
  else {
    digitalWrite(led3,LOW);
  }
}

FFchocobo: So I got this new code, but still won't make it work

Do I have to follow some codes used it making a switch? Do I need I pull up resistor for the input pin?

it depends on how you have your button wired. If you have it hooked up to 5v and an Arduino pin, then yes. I prefer to hook it up to ground and an arduino pin. Then, you don't need a resistor, but instead of input, you use input_pullup, which turns on the arduinos internal resistors and pulls the input line to five volts.

how do you have your switch wired?

I put some comments in your sketch.

#define led 13
#define input1 12
#define led3 11
#define led4 10
#define led5 9
#define led6 8





void setup() {
  Serial.begin (9600);
  pinMode(led, OUTPUT);
  pinMode(input1, INPUT);
  pinMode(led3,OUTPUT);

}

void loop() {
  
   digitalWrite(led, HIGH);
   digitalRead(input1);
   // I would also put this here temporarily.  it will show you if the button is working. it should alternate between 0 and 1 depending on if the button is pressed or not.
   Serial.println(input1);
   if (input1 == LOW) {
    digitalWrite(led3, HIGH);
   
   } 
  else {
    digitalWrite(led3,LOW);
  }
}

[/quote]

report back.

https://opensourcehardwaregroup.com/wp-content/uploads/2015/01/Mutiple-Button-Presses_bb_OP.png

that is how I would wire it, but ofc. it has two leds, you only need one. Not the leds resistor.