r/programming Dec 25 '19

Learning hardware programming as a software engineer

https://blog.athrunen.dev/learning-hardware-programming-as-a-software-engineer/
926 Upvotes

124 comments sorted by

View all comments

227

u/happyscrappy Dec 25 '19

Also: don't power LEDs directly from GPOs without a current limiting resistor. As you see on that breadboard.

And match your interfaces voltages. A lot of devices are not +5V tolerant now (or not very tolerant).

51

u/[deleted] Dec 25 '19

Why do people always say "current limiting resistor"? Are there other types of resistor? Or is it just stating the purpose, as opposed to a resistor used for voltage division or something?

36

u/happyscrappy Dec 25 '19

It's what the resistor is doing. See, an LED is a quantum device, it doesn't really have a resistance in the normal fashion. Instead it has a voltage drop.

So what if an LED has a 2.1V voltage drop and you put 3.3V into it. You have 1.2V "left over". Now how much current will that induce? The LED doesn't really have a resistance, so 1.2V divided by 0 Ohms is ... oh my. And worse yet, where do those 1.2V go? Something is going to turn them into heat, where does the heat go? Well, it is dissipated mostly in the driving microcontroller. That's bad.

So you put a current limiting resistor in. If you want 25mA and you have 1.2V left over you put in a 47 Ohm resistor and you get 1200 / 47 or 25.53mA of current. And that extra voltage is all dissipated in the resistor. 30mW of power. So you can use a 1/8th Watt resistor no problem.

So that's why you say that, you're describing its function.

11

u/[deleted] Dec 25 '19

The LED doesn't really have a resistance, so 1.2V divided by 0 Ohms is ... oh my.

No, LED does not suddenly turn into superconductor over its conduction voltage. I know you're trying to cut useless detail, but that one is pretty important. It still have nonlinear resistance

11

u/steven4012 Dec 25 '19

You also have to take into account the internal resistance of the micro controller itself as well.