My Outputs and Inputs are inverted.

Hello,

I programmed something easy with a button and 3 LED´s, but I can´t undestand why all my Outputs and Inputs are inverted. When I press the button, it schould be HIGH, but in the program it reacts inverted and the same with the LED´s, they light up when in the programm says LOW.

This is my program:

int switchState = 0;

void setup() {
pinMode (3, OUTPUT); // grüne LED
pinMode (4, OUTPUT); // rote LED
pinMode (5, OUTPUT); // rote LED
pinMode (2, INPUT); // Taster

}

void loop() {
switchState = digitalRead (2);

if (switchState == LOW){
// Taster ist nicht betätigt

digitalWrite (3, LOW); // grüne LED
digitalWrite (4, HIGH); // rote LED
digitalWrite (5, HIGH); // rote LED
}

else { // Taster ist betätigt

digitalWrite (3, HIGH); // grüne LED
digitalWrite (4, LOW); // rote LED
digitalWrite (5, HIGH); // rote LED

delay (250);
digitalWrite (4, HIGH);
digitalWrite (5, LOW);
delay (250);

}

} // fängt wieder von vorne an -> kehrt zurück zum loop

Moved your topic to it's current location as it is more suitable.

Could you take a few moments to Learn How To Use The Forum.
Other general help and troubleshooting advice can be found here.
It will help you get the best out of the forum in the future.

This is my program:

It is no surprise to me that people have problems when programming when they cannot follow simple instructions such as those in the sticky post at the top of the list of topics, ie Read this before posting a programming question

Please take the hint and do as is suggested

Please post a diagram showing how your switches and LEDs are connected.