i have just started learning Arduino, so please be patient to me :)
Why doesnt my circuit below doesn't work?
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:
Thank you.
-
"I'm trying to reproduce this circuit that I saw in a tutorial" But your connections don't look anything like that.Ignacio Vazquez-Abrams– Ignacio Vazquez-Abrams2016年06月01日 02:50:34 +00:00Commented Jun 1, 2016 at 2:50
-
Is it better now? s33.postimg.org/z4xey1jxr/now.jpgJonhz– Jonhz2016年06月01日 03:06:42 +00:00Commented Jun 1, 2016 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– Dave X2016年06月01日 04:30:14 +00:00Commented Jun 1, 2016 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– Nick Gammon ♦2016年06月01日 06:17:19 +00:00Commented Jun 1, 2016 at 6:17
-
The code that you posted, is that the same code you put on the Arduino in the image?RSM– RSM2016年06月01日 06:54:23 +00:00Commented Jun 1, 2016 at 6:54
1 Answer 1
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
-
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– Jonhz2016年06月01日 04:04:24 +00:00Commented Jun 1, 2016 at 4:04
-
1Haras' 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– Dave X2016年06月01日 04:34:53 +00:00Commented Jun 1, 2016 at 4:34