Sorry if this is a really basic question - software engineer here, so I'm a little out of my element.

I'm working on an IoT project, and I'm planning on using this button with a red LED inside of it.

For most of their products, this manufacturer lists how much current their stuff draws. However, in this case, they don't. The information they give is:

The forward voltage of the LED is about 2.2V so connect a 220 to 1000 ohm 
resistor in series just as you would with any other LED to your 3V or higher 
power supply.

I'm planning on powering it using a 2N2222 transistor connected to the 5V rail on a Raspberry Pi.

I would have naively tried simple Ohm's law, but I know that can't be correct here.

EDIT: I did a little digging through some old textbooks.

Since I'm powering it from the 5V rail, $$V = 5V = 2.2V_{LED} + V_{RESISTOR}$$


$$V_{Resistor} = 2.8 V$$

Which, from Ohm's law, then gives:

$$ I_{Resistor}=I_{LED}={2.8V\over1000\Omega}=2.8mA$$

Are my calculations/reasoning correct?

  • \$\begingroup\$ Yes, you're on the right track. But you can also factor in the voltage drop in the 2N2222. Simply add it to the V(LED) as a first step. \$\endgroup\$
    – Dampmaskin
    Commented Nov 14, 2018 at 21:59
  • \$\begingroup\$ Your text books are newer than mine :-) ... when I was at high school (last time physics for me) LEDs were not mentioned (thus no forward voltage). \$\endgroup\$ Commented Nov 14, 2018 at 22:21

2 Answers 2


At 5V you have V = I*R equivalent to (5V-2.2V) = I * R(from 220 to 1000 ohm).

The 2.2V varies slightly based on the source voltage but in this case it's safe to approximate that your current would be between 2.8V/220ohm=12mA and 2.8V/1000ohm=2.8mA

2.8mA should be a decent amount for any red LED you're playing with. Blue LEDs can be a lot brighter at the same current so just keep that in mind before you solder anything because there are tons of examples of blue LEDs that are way too bright because somebody expects the same luminance curve.

The 220 ohm resistor would be appropriate if you were running at 3V (would give you ~3.6mA) but at 5V you would have 12mA through the LED which would almost certainly get it way brighter and hotter than you need it to be.

  • 1
    \$\begingroup\$ Awesome! I did some digging through some old textbooks as I knew this had to be really basic, and it looks like I was correct in my reasoning. Thanks for the answer anyways! \$\endgroup\$
    – Bassinator
    Commented Nov 14, 2018 at 21:58
  • \$\begingroup\$ Regarding blue LED brightness, is that why the cheap $1 little chinese made box to convert optical audio to RCA style that I bought on the internet blinds me with the fire of a thousand suns at night in my room? \$\endgroup\$
    – Bassinator
    Commented Nov 14, 2018 at 22:03
  • 1
    \$\begingroup\$ That is to encourage you to crack it open and replace it with a soothing green LED and maybe a bigger resistor. At least that's what I have always presumed. \$\endgroup\$
    – Dampmaskin
    Commented Nov 14, 2018 at 22:07
  • 1
    \$\begingroup\$ There's a wide variation in LED brightness these days. The LEDs of my youth would barely glow enough to see in sunlight at 10mA (hence, a 220\$\Omega\$ current-limit resistor). If you go shopping for high-intensity LEDs today, you can find red ones that are painful to look at with a 3.3V supply and a 1k\$\Omega\$ resistor. There's no knowing what's in your switch unless you check. \$\endgroup\$
    – TimWescott
    Commented Nov 14, 2018 at 22:26

For a LED:

I led = (Vsource - Vled) / R

You can use this calculator to help with deciding on the resistor you would like to use for your 5 volt rail. http://www.ohmslawcalculator.com/led-resistor-calculator

I see each GPIO pin on the Pi can supply 50mA and thus you wouldn't need your transistor and could just turn it off and on with the GPIO.

Yes your calculations are correct. You can reduce the resistance to get a brighter LED.

  • \$\begingroup\$ It is true that the Pi can supply 50 mA cumulatively across all GPIO pins, but I have many other devices on the Pi being controlled by GPIO so I don't want to push it. Also, for any future readers, that is 50 mA combined across all GPIO pins, but no more than 16 mA on any one pin. \$\endgroup\$
    – Bassinator
    Commented Nov 14, 2018 at 22:01
  • \$\begingroup\$ Makes sense. I see that is the maximum you would desire for all pins. \$\endgroup\$ Commented Nov 14, 2018 at 22:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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