# Alternating 3 LED project

**URL:** <https://community.sparkfun.com/t/alternating-3-led-project/35916>\
**Category:** Projects\
**Created:** [October 8, 2018, 8:12pm UTC](https://community.sparkfun.com/t/alternating-3-led-project/35916 "2018-10-08T20:12:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bond7911](https://avatars.discourse-cdn.com/v4/letter/b/58956e/32.png) [@Bond7911](https://community.sparkfun.com/u/Bond7911)\
**Post date:** [October 8, 2018, 8:12pm UTC](https://community.sparkfun.com/t/alternating-3-led-project/35916/1 "2018-10-08T20:12:09Z")

</div>

I am making a Halloween costume for my son and it needs some light. Basically he’s a character from the Mario Bros universe that carries a traffic light on a fishing pole. I am trying to figure out a way to light the traffic lights red, green, and yellow lights using leds in a single circuit that would turn them on and off independently. Just something simple that goes red, then yellow, then green, then back to red over and over. Is there something to build or a circuit diagram? I really have never done any wiring like this ever, so the easier the better. I am sure an arduous could do it, but I have never used one before. I am also hoping for it to be portable and run off a 9v battery, not a wall socket.

Thank you for your help

---

<div class="post-metadata">

**Author:** ![jacquelbot](https://avatars.discourse-cdn.com/v4/letter/j/d2c977/32.png) [@jacquelbot](https://community.sparkfun.com/u/jacquelbot)\
**Post date:** [October 11, 2018, 4:39pm UTC](https://community.sparkfun.com/t/alternating-3-led-project/35916/2 "2018-10-11T16:39:24Z")

</div>

I think this would be simplest with an Arduino. There’s a sample program called “Blink,” it’s one of the simplest possible programs, that could be modified a little to do what you want.

I’m imagining you using 3 LEDs of each color so that you can diffuse the light and have a reasonably large circle for each traffic light. Say you choose resistors to go with your LEDs to pass about 10mA through each LED. If you’ve got 3 LEDs per color, that means that the LEDs will be pulling about 30mA at any given time. The Arduino board itself draws something around 60mA for a total of 90mA - at that draw I’d expect a new 9V battery to last 3-ish hours, probably long enough for a costume, so that’s good.

Check out this page on the blink code:[https://www.arduino.cc/en/tutorial/blink](https://www.arduino.cc/en/tutorial/blink)

You’d need to connect each LED (and its resistor) to a separate pin and in the code you’ll give these pins names by typing something like “int green1 = 2;” (you can see examples of that in the “fade” sample code [https://www.arduino.cc/en/Tutorial/Fade](https://www.arduino.cc/en/Tutorial/Fade))

Then in the “setup” part of the code, you’d set up each of the pins you’re using to be an output like they do in the blink code (substituting your names for LED\_BUILTIN).

Then, in the main loop, you’d turn on all the green LEDs, delay for however long you want the light to stay on, turn off all the greens, turn on all the yellows, delay, turn on all the reds, delay. And there you go!

Be careful to put the input from the battery into the pin labeled “Vin” rather than the 5V or 3.3V pins and I’d use pins 2-10, skip 0 & 1.

Good luck!

---

<div class="post-metadata">

**Author:** ![exeng](https://avatars.discourse-cdn.com/v4/letter/e/3da27b/32.png) [@exeng](https://community.sparkfun.com/u/exeng)\
**Post date:** [October 12, 2018, 12:29am UTC](https://community.sparkfun.com/t/alternating-3-led-project/35916/3 "2018-10-12T00:29:29Z")

</div>

Seems to me that you could adapt a simple circuit like this (see figures 6-7) here-\> [http://www.nutsvolts.com/magazine/artic … r-circuits](http://www.nutsvolts.com/magazine/article/led-chaser-sequencer-circuits)

without using a micro. Simply connect the GRN led to outputs 0-3, YEL led to 4-5, and RED led to 6-9 (or some combination that results in the relative on time for each led). No micro needed but you would have to find the parts (555, 4017B, etc).

---

<div class="post-metadata">

**Author:** ![exeng](https://avatars.discourse-cdn.com/v4/letter/e/3da27b/32.png) [@exeng](https://community.sparkfun.com/u/exeng)\
**Post date:** [October 12, 2018, 12:56am UTC](https://community.sparkfun.com/t/alternating-3-led-project/35916/4 "2018-10-12T00:56:36Z")

</div>

Following up on my previous post… also look at figure 11 where reset is used to sequence only a subset of the 10 outputs. In your case 3 for equal on times.
