I just begun with the Arduino starter kit, and in the second example I would like to test some changes to learn more.
The point is to have a green LED shining, and when pressing the button the two red LEDs blink.
This is the code:
int switchState = 0;
void setup()
{
pinMode(2, INPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
// the button is pressed
digitalWrite(3, LOW);
digitalWrite(4, LOW);
digitalWrite(5, HIGH);
delay(250); // wait for a quarter second
// toggle the LEDs
digitalWrite(4, HIGH);
digitalWrite(5, LOW);
delay(250); // wait fo a quarter second
}
void loop()
{
switchState = digitalRead(2);
// this is a comment
if(switchState == LOW)
{
// the button is not pressed
digitalWrite(3, HIGH); // green LED
digitalWrite(4, LOW); // red LED
digitalWrite(5, LOW); // red LED
}
else
{
// the button is pressed
digitalWrite(3, LOW);
digitalWrite(4, LOW);
digitalWrite(5, HIGH);
delay(250); // wait for a quarter second
// toggle the LEDs
digitalWrite(4, HIGH);
digitalWrite(5, LOW);
delay(250); // wait fo a quarter second
}
} // go back to the beginning of the loop
I added a modification into the schema (a fourth LED in parallel with the green), like this:
But the added LED is not shining. It's a long time ago I finish school and I forgot a lot of things. Am I wiring the fourth LED incorrectly?