A while back I bought some cheap, multi-colour LED modules on ebay. I’m not sure what they were designed to be used for, as each time power was applied they cycled through different colour combinations. The modules had an AT89C2051 microcontroller on the back which would be too bothersome to reprogram, so I decided to do a bit of reverse engineering and control each module externally.
My idea was to create a MIDI controlled array out of the modules, to visualise the notes coming from a piano keyboard. To do this I removed the microcontroller on each module and mapped the circuit layout to find the control lines for each group of LEDs. I decided to build an array of 3 x 4 modules, 12 in total to match the number of semitones in a (western) musical octave. So 12 modules * 3 colours per module = 36 outputs to control. To control this many I ordered some free samples of the TLC5940 from Texas Instruments, which is a 16-Channel PWM LED Driver. With three of these chips I could control up to 48 outputs, more than enough!
For the brains I ordered a ATMEGA 32U4 board from Sparkfun. The nice thing about these boards is that they come with a USB connected bootloader, making them super easy to program with AVRDUDE. The only trick was using the board’s ISP header to reprogram the fuse settings.
To drive the TLC5940 chips, I found an excellent C library and notes written by Matthew Pandina. I then needed to build a MIDI input circuit and connected it to the ATMega32’s UART RX pin. There is a great article on interfacing MIDI signals to and AVR on avrfreaks.net. Next came writing code to put it all together and map MIDI notes to particular LEDs.
The initial source code I’ve written is available here. There are still some bugs so use it at your own risk! Here it is in action: