Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 3 of 3

Thread: PWM 8 LEDs on Teensy 4.1

  1. #1
    Junior Member
    Join Date
    Jul 2020
    Location
    The Road
    Posts
    8

    PWM 8 LEDs on Teensy 4.1

    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.

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    23,012
    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.

  3. #3
    Junior Member
    Join Date
    Jul 2020
    Location
    The Road
    Posts
    8
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •