RGB LED Multiplexed Table

I've been thinking about building a 12x24 rgb led coffee table. the leds would be in 2" squares, the design is similar to this:


Except that instead of 7x16 its 12x24, this means a lot of multiplexing cause with RGB leds itll actually be 864 leds. Unfortunately I have never done any multiplexing before, but i have a VERY basic understanding of it. I learned most of what i know from this instructible: http://www.instructables.com/id/Led-Cube-8x8x8/ I'm still kinda fuzzy in some areas, like how to write the code for multiplexing and clocking the ICs

Some things I want it to do:

-play tetris (need help on the code for this and the one below, but thats for later)

-play snake (low resolution)

-be able to connect an iPod or other such device and be a VU meter (so split some audio into 12 or 24 frequencies) maybe have an amp and speakers in it too. Or maybe just have a microphone for outside noises and music.

-be able to touch each individual square and have it cycle through colors

The last one is what i need the most help on. The others just need some code help. I had the idea to use photocells in each box, so with the leds on it reads about the same voltage, but if you touch the opaque glass above it it gets a little dimmer, so there would be a drop in voltage( i hope). The way i was gonna multiplex was with 10x 74HC574 ICs. cause ill be using common cathode RGBs and all the anodes for one row will be the on the vertical rows. the cathodes of them all will be connected horizontally. So 9 for vertical(3 for each color) and 2 for the horizontal (with a few pins left over). as soon as i can get to a radioshack i am going to test the photocell idea. I was thinking about reading the photocells with 4051s cause they can read analogs n stuff. Maybe the arduino multiplexes voltages to the photocells in a sort of wave motion, going up one row then down another REALLY fast, then when it sees a change in voltage it cycles to the next color for that square.

sorry that this is so poorly written, any questions please ask. If this seems feasible i would love some construction tips or advice on what would work. Im on a tight budget, so no suggestions like ultrasonic sensors for each square please. the main problem i see is that the reading voltage would be so small it wouldnt be effective, and the lighting in the room couldnt vary at all while in use. I would love some feedback and questions, thanks for looking.

What kind of Arduino?

So you 12 columns and 24 rows? Each column is RGB, so output wise you really have effectively 36 LEDs across and 24 rows down. You could drive the 36 columns with the HC574, wrap the output to the next input so it acts like a shift register, will flicker a lot as it loads up. For each row tho, you will have to sink the current of 36 LEDs, for that you need a beefier part. Either a discrete transister per row driven by a shift register output, or an array of transistors like ULN2803 on the output of a shift register. (Tho with a Mega, you'd have enough pins to just buffer its output)

Your code would set the anodes, turn a row on, off, set the cathodes, turn next row on/off, do that quickly and the LEDs will light up nicely. If you left each row on for 5mS, then you'd refresh the table every 0.12 seconds, 8 Hz. Could be flickery. Either refresh faster at higher current rate, or break it up into 4 sections, light up 4 rows at a time for 5mS and achieve 32 Hz refresh rate, comparable to a TV. Definitely want to use SPI.transfer to send the 20 bytes out to the 4 rows very quickly. Then while waiting for the 5mS to elapse, you can be reading the 288 squares for your touch feedback. 5mS/288 = 17uS? for each square? Maybe just read 1/4 of them every LED refresh cycle. Or maybe just read the 4 rows that are being written - as the row is turned on, maybe a hand over square would reflect enough back to be sensed? The demultiplexing back could be set up similar to the multiplexing - 48 inputs (four 1 of 16 demux (12 used) feeding into a 1 of 4 selector into the ADC if going that route) with each of the 12 inputs fed from a 1 fo 6 selector (for the 6 rows in each group of 4).

Quicker way be to have each photocell be paired with an analog comparator, then just have to deal with 0/1s for demuxing, can feed those into a 48-bit shift register and do 6 SPI transfers to read them in, and be able to act on the 1/0s more quickly vs doing gobs of A/D conversions.

ummmm, yeah. Let me do some research on all that. Thanks for all the suggestions so fast! sounds really helpful, especially about the analog comparator. I'll do some research and get back to you, going to radioshack today to pick some stuff up for it. And yeah i was planning on using my mega.

Sorry I meant that the 24 across were what i was going to be using for the RGB switching, so there would be 72, 3 for each color. So i would end up using 3 74HC574s for each color. then two for driving the transistors that would be connected to the cathodes, unless you know of an IC that is like the 74HC574 but has 12 outputs, instead of 8.

Do you think it would be better to use the 12 for the colors, and the 24 for the cathodes?

Are you sure about using the 74HC574 it is a Octal D-type flip-flop.

This project http://www.thebox.myzen.co.uk/Hardware/Hexome.html Has a circuit for a 64 RGB LED matrix.

wow, thats pretty sweet, uhh yeah im fairly new to multiplexing, and thats the only chip i have done research on. got most of what i know from that instructible. if you have something better i would love to hear about it.

got most of what i know from that instructible.

Please please please do not believe anything you read in instructables, most of it is utter rubbish.

For basic multiplexing concepts see:- http://www.thebox.myzen.co.uk/Workshop/LED_Matrix.html

Where you mentioned playing tetris, I figured blocks dropping down thru 24 rows would be a better fit than just dropping thru 12.

It can be made to work either way. 9 bytes of data for 72 columns, and 12 drivers to sink 1.44A of current for each row (with 20mA each LED). Break into 2 groups, writing/reading 2 rows at a time still for 32Hz refresh rate.

SPI to two groups of shift-put registers for LEDs & shift-in registers for capturing photocell output: SCK, MOSI, CS1, CS2, CS3, CS4, and 4 lines to select from 1 of 12 Demuxes that feed each shifin register Use 12 pins to control cathode drivers Couple more for control buttons.

Not too bad.

Im aware of some of the rubbish on instructibles, but you should really check it out. It was very well written and very informative, these people knew what they were talking about.

regarding the tetris, yeah i was intending that the blocks would drob down like the original game, on the 12 rows.

OK got all the stuff at radioshack, but how do i hook up the photocells to the comparator? (its the LM339)

On one input put the wiper of a pot with each end connected to a supply rail. The other input put your photo cell (what type is this as it might change what you need to do) with its other end to ground. Also put a pull up resistor to the positive supply (use 100K). The attach the output to an arduino input and enable the internal pull up resistor.

I tried that, no good. i don't think i hooked it up right, you got a wiring diagram?

Try this:- http://www.ladyada.net/learn/sensors/cds.html

No good, feelin real stupid right now…

As I said before but you didn't answer, what sort of light cell have you got?

sorry, just your basic photocell, got several different sized ones at radioshack, it goes from about 7k ohms in brightish light to about 60-65k ohms in dark.

They are cadmium sulfide, forgot to mention that.

Does this help?

If you can't get it working from that link, then you are doing something wrong. Post a photo of what you have done along with the code.

Yeah, thanks crossroads that was exactly what i was looking for. Unfortunately it still is not working. I know i hooked everything up right, and i wrote two sketches to test it. One is an analog that just prints the output of the pin(im getting 14 every time with no change, no matter where i move the pot) the other is a digitalRead, it just prints HIGH and LOW (again, i am constantly getting LOW)

here is the analog:

int photoPin = A0;

void setup(){

void loop(){

here is the digital:

int photoPin = 13;

void setup(){

void loop(){
  if (photoPin == HIGH)

Also does any one know of a chip like the 74HC574 but with 12 outputs instead of 8?


If you put a meter at the LDR/ground resistor junction (Vldr) what does it measure?