### Node MCU + LEDs - Which Resistors Do I Need?

So you're a Noob? Post your questions here until you graduate! Don't be shy.

### Node MCU + LEDs - Which Resistors Do I Need?#79442

By Loisaida Sam
#79442 Hello!

I've got this traffic light thing happening using a Node MCU and three LEDs.

IMG_20181109_165158.jpg

Specifically, I'm using three digital GPIO pins, each hooked up to a resistor, and then an LED, and then to ground.

Here are the specs on the LEDs from the bag they came in:

IMG_20181206_154849.jpg

I'm wondering what kind of resistor(s) I need to do this efficiently/properly. Maybe I can use that Ohm's Law thing somehow?

I currently have them wired up using 330Ω resistors that I found in another bag. No idea if that's cool, but nothing has exploded, so maybe it is?

Bonus question, does it affect anything to have fewer or more LEDs hooked up like this. Like if I had the same setup with eight LEDs, is it any different (resistor-wise) than if I use the three I currently have hooked up?

Bonus bonus question - is it dumb to solder resistors right onto jumper cables or should I really be using something like a perf board?

Thanks in advance, I have no idea what I'm doing

-Sam
You do not have the required permissions to view the files attached to this post.

### Re: Node MCU + LEDs - Which Resistors Do I Need?#79448

By btidey
#79448 Ohms law and knowledge of how much voltage is dropped across a LED will help you here.

1. O/P voltage from Node MCU Pin when high = 3.3V
2. LED voltage drop (Vf) varies according to colour and a bit with current. Typically at 5mA red/yellow = 1.4V, green/blue =2.5V
3. The current is then determined by the the resistor using Ohms law. Current = (3.3 -Vf) / R

So with your 330 resistor you would get

Red/ yellow = (3.3 - 1.4) / 330 = 5.6mA
Green/ blue = (3.3 - 2.5) / 330 = 2.4mA

The current will determine how bright the LED is. 1 to 10mA is the typical current used but you should aim to use less than 9mA to avoid overloading the GPIO pin driving the LED.

If you drive multiple LEDs from GPIO pins then you should aim to have less than 40mA total. So with 8 LEDs you want less than 5mA per LED.

Soldering jumper lead onto resistors will work but using a perf board is good if you have multiple LEDS as it will help line them up.

### Re: Node MCU + LEDs - Which Resistors Do I Need?#79556

By Loisaida Sam
#79556
btidey wrote:Ohms law and knowledge of how much voltage is dropped across a LED will help you here.

1. O/P voltage from Node MCU Pin when high = 3.3V
2. LED voltage drop (Vf) varies according to colour and a bit with current. Typically at 5mA red/yellow = 1.4V, green/blue =2.5V
3. The current is then determined by the the resistor using Ohms law. Current = (3.3 -Vf) / R

So with your 330 resistor you would get

Red/ yellow = (3.3 - 1.4) / 330 = 5.6mA
Green/ blue = (3.3 - 2.5) / 330 = 2.4mA

The current will determine how bright the LED is. 1 to 10mA is the typical current used but you should aim to use less than 9mA to avoid overloading the GPIO pin driving the LED.

If you drive multiple LEDs from GPIO pins then you should aim to have less than 40mA total. So with 8 LEDs you want less than 5mA per LED.

Soldering jumper lead onto resistors will work but using a perf board is good if you have multiple LEDS as it will help line them up.

This is great! Thank you so much for the insight, it's EXACTLY what I needed to know!

A couple of follow-up questions...

1. Re: question 1: What does "O/P voltage" mean? Output voltage?

2. Solving for resistance, an example:

Say that I have a green LED at 2.0V, so my voltage becomes: (3.3 - 2.0), or 0.7V.

If I want to "safely max out" a GPIO pin at 9mA, I can solve for resistance with: R = 0.7V / 9mA = ~78Ω, right?

Do they sell resistors in roughly this size? Any good suggestions for resistor retailers? The other "bag" of resistors I have on my desk are 10kΩ, so WAY too high, right?

3. Resistor direction

Does it matter which direction a resistor is applied to the circuit? In other words, is there a forwards or backwards? I know this is a noob forum ...

Thanks again!!!
-Sam

### Re: Node MCU + LEDs - Which Resistors Do I Need?#79629

By Morgan
#79629 solder resistors right onto jumper cables:
You can do this, but try not to, because when you move the board, it is easy to have an accident.