Electrical Engineering Stack Exchange is a question and answer site for electronics and electrical engineering professionals, students, and enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am working on a headless Raspberry Pi project. Being headless, I can't visually tell when the system is fully booted and ready to accept tasks. While a Pi doesn't take an inordinate about of time too boot, I am still looking at 30-seconds or so.

What I would like to do is have a bi-colored LED (red-green) that would light up red when when power is applied to the system, but, when the system is ready, my task will pull a pin either high or low, as needed, to switch the LED to green. I do not have any components yet for this part of the project, so I am flexible if it is a two-lead red/green LED or a three-lead red/green LED.

The coding part, I have down. What I could use help with is the circuit.

share|improve this question
    
Any specific reason you want red & green, or a single color at a time? Would you be happy with Red / Yellow (R+G)? Be much simpler. Well, not as simple as two independent leds. – Passerby Jan 15 at 23:46
    
You better check your PI configuration. My average is 10.5 seconds to boot and be ready. Shutdown can take some extra time. WIFI drag some and NTP to sync time. If you need better boot time you can trim and/or reorder boot priorities I like your bicolor idea! – fcm Jan 15 at 23:50
    
@Passerby, just aesthetics, but I understand your point. – Jim Jan 16 at 2:00
    
@Fcm, I will double check my times, it was rather casual when I did it though. But, I am using WI-FI because where I need to use it at does not have wired network available. I'm also not pressed for time, so to speak. 10 seconds, 30 seconds, etc. is fine I just need to know when it is ready. – Jim Jan 16 at 2:02
    
Oh, and the RPI already have a Red Power LED, and a Green "Ok/Act" SD access led by the headphone jack, that can be changed to user control. See raspberrypi.org/forums/viewtopic.php?p=136266 – Passerby Jan 16 at 3:13
up vote 3 down vote accepted

Here's a third way. Does not require that the green LED is powered by GPIO.

schematic

simulate this circuit – Schematic created using CircuitLab

EDIT: I have updated the schematic above, so let's go through the changes in some more detail.

  • I'm assuming that you are building this and not designing a PCB, so I looked for a through-hole transistor. There were not many good logic-level MOSFETs in TO-92 package, so I went for a BJT.

  • The 2N3904 recommended by Passerby would work, but I chose a BC547 because it had a nicer datasheet.

  • The supply was changed from 3.3V to 5V because of the current issues mentioned below. As a result, the resistor values have been increased.

  • Note that the resistors are different. This is because red LEDs have a lower forward voltage than green LEDs. You may need to tweak these values to get the brightness you desire.

share|improve this answer
1  
That's a nice way to do it. Just okay on 3.3V I think. – Spehro Pefhany Jan 15 at 23:47
    
@SpehroPefhany I guess we were thinking along the same lines. – Armandas Jan 15 at 23:53
    
Armandas, I like the idea of not driving the LED off of the GPIO, so I think I will go this route. SpehroPefhany made the comment about "Just okay on 3.3V..." Would I be better off running off of 5.0v instead? The power input to the Pi is 5v, so it is doable. I already have a 5v power supply that I could tap off of, so it wouldn't even have to be powered through the Pi. – Jim Jan 16 at 2:57
    
Also, software I understand... Electronics, not as much. You left the mosfet generically speced as M1. How do I determine what the right one is? Thanks again. – Jim Jan 16 at 2:59
    
The mosfet should be any N-Channel mosfet with a VGS of 3V. Or use a common NPN transistor (2n3904) with a base resistor of 10k. @jim – Passerby Jan 16 at 3:01

schematic

simulate this circuit – Schematic created using CircuitLab

Don't forget to connect the 3.3V supply to the gate as required.

share|improve this answer

Here's one way:

schematic

simulate this circuit – Schematic created using CircuitLab

A 2-lead LED circuit:

(you can use a DIP 74HC00 if you want to use a breadboard)

schematic

simulate this circuit

share|improve this answer

And to add to the list, an approach using just the LEDs and two resistors:

schematic

simulate this circuit – Schematic created using CircuitLab

This one has the advantage of not wasting as much power shunting current away from the red LED. The down side is that the GPIO pin would need to be at 0V during boot. Thinking about it, that may not be the case.

If the IO pins are High-Z during boot, you could add a buffer in to the circuit with a pull down resistor - this would convert the High-Z to an output low.

share|improve this answer
1  
This method can even be used on 5V with a small modification. See this EDN article. ;-) – Spehro Pefhany Jan 16 at 1:10
    
@SpehroPefhany I think the bigger issue is that the IO pin is probably High-Z during boot (giving yellow as both LEDs would turn on). Adding a Not gate or buffer would solve both issues - the buffer would convert high-z to a driven low, and if supplied with 5V it would also work with a 5V supply rail. – Tom Carpenter Jan 16 at 1:46
    
@TomCarpenter depends on the Vf. Circuit lab's simulation shows .7mA going through the circuit at 3.3V. May not even be noticeably on. – Passerby Jan 16 at 2:39
    
@Passerby if the IO pin is driving high, there will be zero current through the top LED - how can there be, no voltage across it. If the IO pin is driving low, there will be no current through the bottom LED - again, no voltage across it. Unless you mean with 5V in which case I was referring to if a buffer or not gate supplied with 5V was added to the circuit. – Tom Carpenter Jan 16 at 2:43
    
@TomCarpenter sorry, I meant with the High-Z. It's unlikely both will turn if the pin is tristate or input. – Passerby Jan 16 at 2:59

schematic

simulate this circuit – Schematic created using CircuitLab

Circuit 1, 2 and 3.

Circuits 1 and 2. Two extra components. Circuit 1 shunts the red LED current so it's more wasteful of power.

Circuit 3 lights the red LED initially but when the GPIO turns on the forward voltage drop of the green LED is less than the forward voltage drop of D7 and the red LED combined so the red turns off. Only three components total!

@Passerby points out that the RPi GPIO won't drive this very well since the outputs are 3.3 V. Understanding Outputs documents that with the output drive strength set to 8 mA the output voltage can be as high as 3.0 V with 10 mA source current so, as far as I can see, it should work.


schematic

simulate this circuit

Circuit 4. High side transistor switch.

On Circuit 4 both LEDs are powered from 5V (or 3.3 V, if required). Red LED lights on power on. Green LED lights when GPIO enabled and pulled to ground. Note that to switch this circuit with 5 V supply and 3.3 V LED the GPIO would need to be tri-stated to turn the LED off.

share|improve this answer
    
Updated with Circuit 3. – transistor Jan 16 at 0:02
    
3 won't work well. The GPIO is 3.3V and limited current sourcing. – Passerby Jan 16 at 0:37
    
@Passerby: Thanks. I hadn't read up on that. I did a bit of research and I think it could work OK at 8 - 10 mA. Pin max is 16 mA. See the update. I dropped the cathode resistor value to help a little. – transistor Jan 16 at 0:59
    
The other two should be fine at 5V I think. The draw on the 3.3V regulator should be as minimized as best it can. – Passerby Jan 16 at 1:03
    
@Passerby: Done. (1 & 2 put back to 5 V.) I have used two RPi boards but had very simple IO requirements and didn't play around with them too much. – transistor Jan 16 at 1:08

Simplest circuit, nothing needed but a Common Cathode 3 Pin Red/Green led (there are other colors and pin types as well fyi). Instead of Red On, Green Ready, It's Red On, (Red+Green = Yellow) Ready. As long as the GPIO is High-Impedence/Input or Low while booting, and you set it high when the system is ready.

schematic

simulate this circuit – Schematic created using CircuitLab

Resistors chosen for 6mA on either led which is plenty bright for an indicator (unless you want to light up the room). Used 5V for the red power led, as using too much current on the 3.3V regulator is not a good idea.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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