2
\$\begingroup\$

I'm trying to design an LED circuit for a model that will allow me to change the color of a bi-color LED each time the power is cycled. In other words:

  • Power off: Nothing
  • Power on: Green
  • Power off: Nothing
  • Power on: Red
  • Power off: Nothing
  • Power on: Nothing
  • Power off: Nothing
  • Power on: Green, etc. etc.

Or, if the green/red/off/green... cannot work, can I do a green/red/green/red... instead. I'm NOT looking for flashing, but a steady light that only changes color when the power is cycled (off-on). No components have been purchased, but would like to do this with 3mm or smaller two-color LEDs. My skill level is beginner/intermediate, so the simpler the better. And of course, if I'm barking up the wrong tree, let me know.

\$\endgroup\$
  • 2
    \$\begingroup\$ Welcome to our site - unfortunately your question is not a good fit for our format, because you do not ask a specific question. That being said, you'll need some kind of memory to track the state, which, unless the circuit will be continuously powered even when "off", is probably best implemented with the EEPROM of a microcontroller. I'd suggest you start playing around with that idea (maybe get an Arduino to prototype with), and if you get stuck, by all means ask a question and we can help. \$\endgroup\$ – Chris Laplante Feb 25 '14 at 17:18
  • 2
    \$\begingroup\$ Is there always some power available and this thing is doing the switching, or is power to it shut off to it without warning? \$\endgroup\$ – Olin Lathrop Feb 25 '14 at 17:26
1
\$\begingroup\$

I noticed the "model-railroad" tag, and this question takes me back to the trains of my childhood. That feature was present, and of course it was done by a mechanical rotating switch, and you would interrupt power momentarily in order to activate it.

You could do the same thing using a microprocessor. You can get them with on-board EEPROM in which you can save a counter value. This count will dictate which light pattern to run. You would want to provide enough power storage (capacitors) to let it complete the EEPROM write. Also enough to keep it from switching to the next pattern if there are glitches (of which there are plenty when power is taken off the track using the wheels).

The rest is straightforward microprocessor work, but of course it's not trivial if you've never worked with them before. The chip I looked at costs a dollar, looks just like a 555, and if you only need 2 LED's and can run them at 10mA each, add a resistor for each one and you wouldn't even need any transistors to drive them. Then the rest, as they say, is a "small matter of programming".

\$\endgroup\$
  • \$\begingroup\$ Heck, use one of the pic10f, 3 gpio and the size of a large grain of rice. Perfect for a model train. \$\endgroup\$ – Passerby Mar 28 '14 at 5:53
0
\$\begingroup\$

Something along these lines should do. Note that this is a T flip-flop, but you might just as well use a standard D flip-flop and connect the inverted output \$\bar{Q}\$ to the input. The idea is to clock the flip-flop with the switch and use the outputs to control one of the colors each, while also powering the LEDs through the switch. Note that the flip-flop should be continuously powered (not shown in the schematic). The LEDs and transistors are just the first ones showing up in the schematic editor, while the resistors have quite reasonable values although the 100 \$\Omega\$ ones may have to be changed depending on the specific LED. If the flip-flop can support enough output current for the LEDs you can skip the transistor stage.

schematic

simulate this circuit – Schematic created using CircuitLab

\$\endgroup\$
  • \$\begingroup\$ Switch bounce will keep this from working as the OP desires. \$\endgroup\$ – George White Feb 25 '14 at 23:14
  • \$\begingroup\$ Not with a glitch free switch, which in turn is not so hard to obtain. \$\endgroup\$ – Oscar Feb 26 '14 at 6:24

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.