I'm new to this can someone with more experienced help me?

I had to make a program which:
When pin1 = LOW, turn led1 HIGH
when pin1 & pin2 = LOW, turn led2 HIGH
when pin3 = LOW & pin2 is HIGH, turn led3 HIGH
i’ve gotten this far and i don’t know what’s wrong can someone help me?

verkefni_11.ino (997 Bytes)

void loop() {
     // When pin1 = LOW, turn led1 HIGH
    if (digitalRead(pin1) == LOW) 
        digitalWrite(led1, HIGH);
    // when pin1 & pin2 = LOW, turn led2 HIGH
    if (digitalRead(pin1) == LOW && digitalRead(pin2) == LOW) 
        digitalWrite(led2, HIGH);
    // when pin3 = LOW & pin2 is HIGH, turn led3 HIGH
    if (digitalRead(pin3) == LOW && digitalRead(pin2) == HIGH) 
        digitalWrite(led3, HIGH);
}

Since you have set no conditions when any led output is set LOW they will eventually all be HIGH.

Use

if (digitalRead(pin1) == LOW) digitalWrite(led1, HIGH); else digitalWrite(led1, LOW);

I hope I have the tin tax correct. Use curly brackets for more than one statement in the else routine

Hope it helps