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