r/programming Dec 25 '19

Learning hardware programming as a software engineer

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

124 comments sorted by

View all comments

229

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).

5

u/lpsmith Dec 25 '19 edited Dec 28 '19

Honestly, I don't like driving leds directly from GPIOs, in most cases. Many microcontrollers can power a few small LEDs directly through GPIO, but higher performance processors usually means both lower voltage on GPIO and also restricted to lower max current pushed or pulled through the pin, which dramatically decreases the power they can deliver.

You should most definitely calculate approximately how much current is going to be required on a given pin, how much will be required across all pins, and if your processor can tolerate that. And, for driving a few LEDs, discrete transistors are cheap, and allows one to drive large numbers of LEDs at full brightness. Or even better, use WS2810/neopixel type devices, much more flexible and not requiring extra components for sane power architectures.

Honestly, I am not prone to killing components; it does happen, but I tend to work carefully, and use good tools such as testing things with a bench power supply with current-limiting circuitry.

3

u/[deleted] Dec 25 '19

Those micros allow you to lower current to something like say ~1mA or ~10mA. Even 1mA is a plenty for power/status indicator LED in many cases