24-channel LED driver with 8 bit per channel PWM

Warning message

The Propeller Object Exchange system is decommissioned and replaced with a GitHub repository to house the same existing and future Propeller objects. As of 12/5/2019, this site is read-only. You can continue to browse and download objects from here for a limited time; however, please begin using the Parallax Propeller repository for future reference.
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1
Request group membership
By: created: 2014-03-28 | updated: 2014-04-03

Pulse width modulated LED driver with 24-channels, 8 bits (256 levels) of intensity per channel.

The driver runs in a single cog (2 cogs if using the I2C slave interface) and uses successive approximation at high frequency to provide flicker-free output.

The driver uses a very simple API: The driver continuously reads intensity values for each channel from a user-supplied 24 byte array.  To set a channel's intensity simply write a byte to the appropriate entry in the array.

Sample code is included both for standalone use and for remote control over I2C.

Example circuits are included for controlling 12V RBG LED modules such as the Ikea Dioder.

This module is hard-coded to output on pins 0 through 23.

Release history:
2014-03-28 v1.0 • Initial release
2014-03-30 v1.1
• Various bug fixes and other updates to low-level driver ("24-channel PWM.spin")
• Documentation clean-up and corrections

Latest version is 24-channel PWM v1.1.zip which contains important bug fixes.

Original File Upload
Package icon 24-channel PWM v1.1.zip18.87 KB
Package icon 24-channel PWM v1.0.zip18.25 KB


In the 24-channel PWM object's start method the address of a stack parameter is passed to PASM and the method then exits immediately thereby invalidating said address before PASM had a chance to read from it. Either use/force long aligned arrays and pass their address as is (sidestepping par's 14 limitation) or make sure PASM reads the value before the method returns (e.g. by monitoring said address against zero or NEGX).

Thanks for catching that bug.  I've uploaded a new version that waits for a signal from the ASM code before returning.