I need more PWM ... buy another Leonardo?

My project requires controlling a number of servos and I'm wondering if buying a second Leonardo is my best option.

Dragon Outputs (from Arduino):

Rage - Digital to 3V LEDs, Analog to TIP120 for 12V LED strings

Breathing - PWM to Nose Servo, Digital to 3V LEDs,
Digital to ?? for on/off 12V Inhale Fan,
Digital to ?? for on/off 12V Exhale Fan,
Digital to ?? for on/off 12V Dry-Ice hot water pump

Talking - Digital to ?? for Left Lip Servo either at 180 or 0 degrees
Digital to ?? for Right Lip Servo either at 180 or 0 degrees
Digital to ?? for Jaw Servo either at 180 or 0 degrees

Blinking - PWM to Left Lid Servo, PWM to Right Lid Servo

Looking around - PWM to Eyeballs Servo

Dragon Input (to Arduino):

Rage Amount (Pot) - Analog
Eyeball position (Pot, 0 = fully left) - Analog
Eyelid position (Pot, 0 = fully closed - sleeping) - Analog

Left Lid raised in surprise (on/off toggle) - Digital
Right Lid raised in surprise (on/off toggle) - Digital
Breathing paused in surprise (on/off toggle) - Digital

Talking (pushbutton) - Digital ... appears to talk as long as pressed

Thats 12 digital I/Os, 4 Analog I/Os, and 4 PWM outputs

It appears that a single Leonardo can handle this, but I would sure appreciate a critique of the above. I'm a novice ... just learned last week what a PWM is and just read today about the TIP120.

For example, can a digital port be used to control a servo as long as it only needs to be fully on or fully off ... moving as quick as it can? If so, what component will do that? If not, how should I get more PWM outputs?

Thanks in advance

You don't need PWM pins for a servo. Any of the I/O pins will do. However that may not affect your arithmetic.
The PWM pins are used with the analogWrite() command, not the Servo library.

You can extend the number of simple I/O connections with a shift register.


You'll also need a digital to analog converter (DAC) for analog output, since analogWrite is not analog.

Thanks much for the quick replies.

I'll google-research for links to beginners-guides on implementing/understanding DAC and shift registers.

There are also led controller/driver chips that do PWM on their output pins.

They connect like shift registers, you can add them in chains as PWM pin multipliers.

Looking at what you have so far, it would appear that a single leonardo would do the job quite easily. If you're expecting to build on it though (ie have more input/outputs later) it might be worthwhile getting a mega2560 now rather than later. It's got more i/o than you can shake a stick at and a lot more memory (both flash and sram).

Using these I can add more 12-bit PWM to any Arduino than I'd probably ever want, 16 pins at a time.
That's right. Instead of 0-255 PWM, 0-4095 PWM.

OTOH I could buy a Mega2560 (gots, just because) and get 15 8-bit PWM pins and then work the CPU to toggle some more.

Arduino Playground on PWM driver TLC5940

Texas Instruments TLC5940

The TLC5940 is a 16 channel PWM unit with 12 bit duty cycle control (0 - 4095), 6 bit current limit control (0 - 63), and a daisy chainable serial interface. It is handy for expanding the number of PWM outputs available. The datasheet is available at http://www.ti.com/lit/gpn/tlc5940.

Prices vary widely by source and quantity and they do come in DIP and surface mount packages.

Learn to add chips to an Arduino and learn to make your own stand-alone-AVR-duinos.

When you can do that you can turn a big project into smart modules, each with smaller code than one board trying to do everything.

Thanks much, excellent tips from both of you.

I'm returning the Leonardo and ordering the Mega2560.

I like the idea of eventually building smart modules. At some point, I'm going to add dragon arms and want to have claws that light up and move. Idea is to have it appear to be coming out of a portal (mirror), with only its chest, arms, head and shoulders in our world. I could see building smart modules for the hands.

I'll keep you posted, and add a video in a few months (head only).