Led

I'm planning on driving this: http://www.sparkfun.com/commerce/advanced_search_result.php?keywords=COM-08033&x=17&y=11 http://www.sparkfun.com/commerce/product_info.php?products_id=7835

From an arduino, this means driving 16 LED's and recieving 16 button press, I'm using VVVV to control the board. What do I need to wire it up?

I have the option of just using a joystick for the buttons, and just sending signals to turn the led's on and off.

I've got loads of experience on VVVV, but not a heck of a lot with the Arduino.... yet.

You, Mr. superflyshlnz, have a pin count problem and a current problem.

Lets look at the buttons first.

You have 4 rows and 4 columns. The way one would typically read this is to attach all 8 connections to digital pins on the Arduino. The four column pins you would program as inputs with their pull-up resistor turned on.

pinMode(COL1,INPUT);
digitalWrite(COL1,1); // yes, we just wrote an input, but it puts the pull-up resistor on
... repeat for other 3 columns

Then you cycle through the rows and one at a time tie them to ground. With the row grounded you look to see if any of your columns just went low, if they did then you know a (row,column) pair of a closed switch.

// All your rows should be digitalWrite()d to 0 and set as inputs before you do this, do it in init()
for( r = ROW1; r <= ROW3; r++){
  pinMode(r,OUTPUT);
  for ( c = COL1; c <= COL3; c++) {
    if ( digitalRead(c) == 0) {
      // do something because switch (r,c) is closed
    }
  pinMode(r,INPUT);
}

There is a danger lurking in your board if you do this. The code I showed won’t do it, but if you program a column as a high output and a row as a low output, or some rows as high outputs and some as low outputs then a switch press will make a short and overload your IO pin. To not have an “explode” command available in your software it would be polite to put a 500 ohm resistor between each pin and the switches.

That’s 8 pins down. Now lets look at the LEDs. 16 pins. That’s a problem. Let’s look at the current. You will probably want to throw 20mA through each LED, but the common row lines will have to handle 12 times that. Your Arduino has really great pin drivers, but they won’t do more than… hmm… 40mA I think? 20mA is a nice safe number. You’d almost think you could drive the columns directly… but also buried in the ATmega spec is a total current limit of something like 300mA and 12 * 20mA is getting pretty close so you’d have to read and understand that limit.

I started to suggest you use a pair of 8 bit power shift registers (like TPIC6B595 from sparkfun) to get the 16 high current drivers, but your LEDs are common cathode (they share a ground) and the shifters at sparkfun only pull down so that isn’t going to work. Then I thought a pair of Maxim 7219s (8x8 LED matrix driver popular among Arduino users), but I don’t think that is going to work out easily. There is a maxim display driver that fits your geometry, MAX6955, but it is $24 for one at digikey and it is a 40 pin package. You’d be on your own for interface code. I think I’d lean toward a pair of 8 bit powered shift registers. I’d let 4 bits of the one handle the row lines, and the remain 12 bits I’d drive a simple one NPN transistor inverter on each to handle the columns. Its a lot more soldering and wiring, but lots of simple parts instead of one big complicated one.

I’d also watch this thread for a couple days and see who has a brilliant solution before I start soldering.