By: Tate McGeary

The first issue with using the Arduino Micro or any ATmega32U4 processor for servo control exists in the tlc_servos.h. The issue in the H file is in the timer set ups. The servo control is not for the ATmega32u4. In order to fix this the group created an H file titled “tlc_servos_atmega_32_u.h”. The timer set ups for this file were found from an Arduino.cc forum post about the TLC5940 and the Leonardo on page 2, post #22 from user sparkle_muffin. By using this file the timers for an ATmega32U4 were set up accordingly for servo control.

The primary issue with the TLC5940 is the lack of support for the Arduino ATmega32U4 microprocessors. If one were to go into the library of the TLC5940 and into the pinout folders they would find an “ATmega_xxU4.h” absent. In order to compensate for this, the group devised a way to create an “ATmega_xxU4.h” file through a combination looking at the “ATmega_8.h” and “Teensy_xxU4.h”. The first step in assuring an “ATmega_xxU4.h” file was to look a the wiring diagram for an Arduino UNO which is available at the same website where the TLC5940 library is located. The next step was to look at other projects using the TLC5940 and compare the wiring and differences. Both links provided give the same diagram confirming the wiring for an Arduino UNO.

The next step for making an “ATmega_xxU4.h” file is to look at how the TLC5940 works, for those who do not want read the blog post know that the TLC5940 uses the SPI interface. This means that the TLC5940 needs to be connected to certain pins on the Arduino boards. In this case, the TLC5940 requires: the MOSI pin for serial output, SCK pin, OC1A pin, OC1B pin, and OC3B pin. Respectively on an Arduino UNO pins D11, D13, D9, D10, and D3. The pinout of an UNO is then compared with the pinout of a MICRO in order to check pin placements, both pinouts provided by Pighixx and can be found at his website. When comparing the pins the MICRO layout for the TLC5940 becomes

UNO  ->    MICRO
D11      ->       MO
D13     ->       SCK
D9       ->       pin 9
D10     ->       pin 10
D3       ->       pin 5

Do notice that some of the pins in the pinout for the UNO are different for the MICRO, the obvious is that instead of OC3B, the MICRO uses OC3A.

The pins for the MICRO were confirmed based off of the “Teensy_xxU4.h” file. This is because the “Teensy_xxU4.h” is for a custom board that uses an ATmega32U4 with a different pinout then Micro; however, the H file for the custom board has commented the correct ports for the MICRO and the pins  required for an ATmega 32U4 are as follows:

MOSI: for serial input

SCK: Serial Clock input

SS: No input, but has to be set

OC1A: for XLAT

OC1B: for BLANK

OC3A: for GSCLK

By taking the “Teensy_xxU4.h” file the group went and found the pin control designations from Pighixxx’s pinout. The Teensy boards have a different pin designation compared to an Arduino board, using the pinout of the Arduino Micro, the group changed the naming to the correct designations.

MOSI: PB2 (Port B 2)

SCK: PB1 (Port B 1)

SS: PB0 ({Port B 0)

OC1A: PB5 (Port B 5)

OC1B: PB6 (Port B 6)

OC3A: PC6 (Port C 6)

The last item that needs to be modified is the “chips_include.h”. This file just needs to have the “ATmega_xxU4.h” added in the code at the #elif defined (__AVR_ATmega32U4__).  Add the following or just take the file from the linked above.

/*Uncomment the #include for which ever board
is being used. Default is for the
Arduino Micro*/

/* Arduino Micro 32u4*/
#include “ATmega_xxU4.h”

/* Teensy 2.0 */
//#include “Teensy_xxU4.h”

Follow this link for the wiring for the Arduino micro.

Below are two short videos, one demonstrating the TLC5940 on an UNO and another for the TLC5940 and the MICRO proving that the device is in working order.