0

i have just started learning Arduino, so please be patient to me :)

Why doesnt my circuit below doesn't work?

enter image description here

Here's the code:

#define led_green 2
#define led_yellow 8
#define led_red 13

void setup() {
  pinMode(led_green, OUTPUT);
  pinMode(led_yellow, OUTPUT);
  pinMode(led_red, OUTPUT);

  // Strarting all turned off
  digitalWrite(led_green, LOW);   
  digitalWrite(led_yellow, LOW);  
  digitalWrite(led_red, LOW);  
}


void loop() {
digitalWrite(led_red, HIGH);

delay(1000);

digitalWrite(led_red, LOW);
digitalWrite(led_green, HIGH);

delay(1000);

digitalWrite(led_green, LOW);
digitalWrite(led_yellow, HIGH);

delay(1000);

digitalWrite(led_yellow, LOW);

}

I'm trying to reproduce this circuit that I saw in a tutorial:

enter image description here

Thank you.

5
  • "I'm trying to reproduce this circuit that I saw in a tutorial" But your connections don't look anything like that. Jun 1 '16 at 2:50
  • Is it better now? s33.postimg.org/z4xey1jxr/now.jpg
    – Jonhz
    Jun 1 '16 at 3:06
  • No. The outputs all are shorted directly to the GND rail, and could damage your arduino. Also the top-ends of the LEDs are shorted to the bottom ends of the LEDs, so no current will flow through them.
    – Dave X
    Jun 1 '16 at 4:30
  • The tutorial you showed has the LEDs "jumping the gap" in the middle. You can't move them to one side like you did. That just shorts them together.
    – Nick Gammon
    Jun 1 '16 at 6:17
  • The code that you posted, is that the same code you put on the Arduino in the image?
    – RSM
    Jun 1 '16 at 6:54
5

If you are doing what is in the first picture then you're doing it wrong.

You have to make sure the led is horizontal, not vertical. The signal is going through the led and not making it into ground. And your ground is in the same lane as your signal.

I think you should learn how breadboards work and then move on from there. Its pretty simple and I think you'll learn it quickly.

For your code part, instead of defining the variables, you could just use int.
Refer to this as a starter tutorial, https://www.arduino.cc/en/Tutorial/.
This how the breadboard is connected underneath.

This is how your wiring should look like if you followed the tutorial, enter image description here

2
  • Thanks, i 'll look into it... just one thing, though: it looks to me that the led is vertical in the picture of the tutorial!
    – Jonhz
    Jun 1 '16 at 4:04
  • 1
    Haras' circuit is fine. The 'verticalness' in the pic you posted has the leds bridging the center gap, and the resistors jumping to the common GND rail. Contrary to your circuit, Haras is twisting the LEDs sideways so both terminals of the LEDs are not shorted together, but are on different 5-tie-point segments on the breadboard.
    – Dave X
    Jun 1 '16 at 4:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.