PWM 8 LEDs on Teensy 4.1

Status
Not open for further replies.

even_rats

Member
Hello!

I'm using a Teensy 4.1 for an audio project. I'd like to use 8 LEDs as indicators, and be able to dim them on or off smoothly. I'm assuming I'll need some external chip to achieve this. Any suggestions?

The application will probably use a decent amount of CPU, so whatever solution shouldn't take up too many cycles. For this reason I've ruled out the SoftPWM library.
 
Teensy 4.1 has plenty of PWM pins, so you can probably just use 8 of those. Just use analogWrite(pin, value) to control them, perhaps with something like elapsedMillis in loop() or IntervalTimer to periodically change the PWM setting for the smooth fading. These functions are very efficient and will use very little CPU time.

If you're using blue or deep green LEDs that need more than 3 volts, or if all 8 LEDs will need a lot of current (like 20mA each) you might want to use a buffer chip between Teensy 4.1 and the LEDs.

With audio you should plan the LED ground current path, so you don't get any of the LED current flowing through analog audio grounds.
 
Cool, I misunderstood something I read about analog output on 4.1. That makes more sense!

And thanks for the grounding advice. I hadn't thought of that.
 
Status
Not open for further replies.
Back
Top