Simple dumb LED on PWM pins question

Status
Not open for further replies.

rtrski

New member
Hi all. Have a simple button box project but with a small screen (from Teensy, the little ~3in LCD they offer) and a Teensy 3.2. I Intend to have 5-8 small single color LEDs inside the box to provide backlight to the button panel. Goal is to mimic the Elite Dangerous in-game pilot interface, shown here, so most of the LEDs are cyan, a couple will be amber:

s1DkEsa.jpg

I've done buttons before, comfortable with them, and this will just be simple momentary microswitches, no pots or encoders (this side - "right hand" panel will have both). This question is about also just using the Teensy to provide the current to some LEDs for lighting effects. I know the T3.2 has a per-pin current limit and a total current limit. The LEDs purchased are all in the 3.3V 20mA 'typical' run range, and should give plenty brightness at low current draw, but my intent was to put them on some PWM pins and run them at lower duty cycle to dim as needed and hopefully extend lifetime. The question is, do I really need the resistor in line with each LED?

Basically I guess my question boilds down to: is the per-pin current limit "controlled" by the Teensy (e.g. it can't deliver more) or is simply a ''rating" (It'll provide as much as the load defines, until I kill it, user must make sure it *shouldn't* demand more)? Even the simple tutorial using an RGB LED shows placing a 220ohm R on each channel. I would use one LED per PWM pin up to a small number max in case I need to have a few slightly brighter than others to help the backlit clear 3D print difuser glow more 'uniform'. I'll make a small circuit board that sources 5V off the USB input to provide the screen some power (powered hub between the whole mess and the computer), lets me place the microswitches under my 3D printed button forms, and place the LEDs as well. So I can add resistors as needed, I just don't 100% grasp if I need to.

I did search and for example found some threads with for example powering a single Neopixel with no resistor indicated, but Neopixels have their own driver so maybe that's a poor example vs. the tiny surface-mount LEDs I've picked. (https://www.digikey.com/en/products...tRDFTcnc1VThzUm9rWWFseW1IUEtXQ3c5bGJiUVQifQ== )

Worst part of the dumb questions is I actually am a EE, but microcontrol and active circuits are well outside my normal work. I do electromagnetics mostly (antenna design, waveguides, that sort of thing...all just metal and dielectric to shape the waveform in space, tune the frequency response and impedances. I fail at anything transisitory. ;-) ) I did successfully build one other button box already with a Teensy3.2, including 1 encoder, but the "lights" on that panel are all totally separate lighted switches for 12V power distribution to/from other things. (The panel has 12V in, several switched 12V outs, and the Teensy in there is powered with a buck converter turned down to about 6V on one of those switched lines, with the little backside trace scratched off between Vin and VUSB on the Teensy itself, so I can switch the buttons on or off vs. unplugging the USB cable in that case).

NUXNm8Qb.jpg
 
Yes, you need resistors to limit the current of a bare LED. The Neopixels and similar have built in controllers that manage LED current. (worth learning as you can do all sorts of interesting effects with a fixed number of pins. like changing backlight color and such)

Note also that the individual pins have max current limits over which you risk toasting the teensy. See this chart You should avoid exceeding those limits. Ohms law is your friend, get to know him well.
 
Thanks for answer.

I am using Neopixel or Dotstars or equivalent on another project, just bitbanging them (a string of 'backlights' and the eye light for a HAL 9000 front case ornamentation). In that case I fed the LED strip power direct from 5V from one of the computer PSU's spare Molex connectors. This is the first time I've considered just letting the Teensy itself supply both the LED current and brightness control directly, since I didn't need or want color control, and I just didn't know if the Teensy itself had inbuilt current limiting on those pins. (Interestingly enough the Dotstars respond just fine to the 3.3V logic without a LLC, but I am only controlling 3 subsidiary strips of max 12, probably wouldn't work if that project had to go longer.) Early pic in work - I'm not doing "much" with the programming, just subtle breathing/white balance shift for the backlight, occasional pulsing of the red. But I've considered adding a random number loop to kick in a 'disco mode' for a few seconds just for comedy purposes.
BgTg3G6b.jpg

Appreciate you saving me from Teensy abuse on THIS project though. Just slapped a cut from a reel of 330ohms into the shopping cart and will wait on them before I try any sample wiring of any kind. That should limit me to the pin max and if I go PWM on top of that I think I'll be ok. Only anticipate total load on that project at like 5-7 LEDs and all the rest will just be simple momentary switches, then the data to the ILI9341 (won't use touch on it, just have it scrolling in-game-context gibberish, perhaps reacting to button presses somewhat).
 
Status
Not open for further replies.
Back
Top