PWM breakout

After starting off thinking that the on board Arduino Mega’s 14 PWM pins would be enough, I quickly found that this would never work. Apart from The starting limit of 14, pretty much any extra shield you plug is wants one or more of these pins. Ethernet shield wants pin 10, SD reader wants pin 4, Serial comms wants 0 and 1 (I know that you can change this in the library but my experience with changing core code has taught me better; keep it standard!).

Welcome to the world of breakout boards!

I first started using the Texas Instruments TLC5940 breakout board. Loved it, by using SPI and six or seven pins you get 16 (or multiples there of) high res PWM pins to play with. The only reason I stopped using this is that when I can to buying some more I found the AdaFruit equivalent with the PCA9685 chip. Loved it more. Using the I2C protocol, you only need power, and two others pins and your are set.


The only fine print is that I2C runs at 3.3V, Arduino logic runs at 5V. The Mega doesn’t seems to care about this with the PCA9685 but the nano does. Easy to get around though, either power off the 5V pins on the Arduino and then use some pull up resistors (4.7Kohm) on the signal lines to +5V as a voltage shift. The alternative is to bidirectional level conversion module to do the work for you:


Both achieve the same result.

The PCA9685 can drive 16 channels by either drain or source (can be changed programmatically) but only relatively small amounts (10mA source or 25mA sink). This is obviously not enough to drive the type of down lighting that I am going for but connection the shield to some mosfets is easy enough. You can do it by hand if you are that way inclined but I am all for off the shelf solutions; easy to replace. easy to scale and much easier to use. I bought a small stack of these:


to do the heavy lifting, MOSFET4 shield (version 4, this version is a much cleaner than the v02 that I was using, the V02 had separated opto-couplers for each channel and the LED placement was not ideal) has four irf540n MOSFET’s capable of draining 33A at 10V. This is, once again, overkill as I am limiting every channel to 10A max with a simple fuse but it is good to know the power is there.

Using this setup means that all the major components are plug and play, no soldering and hot swappable. The PCA9685 also stores the value of each channel independently of the control device so you can update the Arduino code without affecting the current lighting state. Current code has just had the Adafruit library added, I did test another library but didn’t have great success with it and this one was clean and simple.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s