SP Button Pad Controller ACT I (latency is a biatch)

Next step for my project, were the Button Pad Controllers. There are two boards, SPI slave board, and a USB master board with USB API. Should be straight forward, or so I thought..

The USB board had two JST connectors, one for the USB cable and one for 5V Power. To make my life slightly easier, I also got a USB breakout board and finding out which was the right way to solder the cables was matter of reading through the product comments since it was not documented.

With the board oriented with the LEDs down, and the ICs facing up, turn it so that the USB JST connector is on the left side
The pins (from top to bottom) are:
USB Data -
USB Data +

Now the tricky part was that each board had to be individually configured for the number of boards in the whole system, for the USB, big deal, just send $0302\r over serial and job done. Now the SPI board is a different story. The documentation showed a waveform diagram of signals it had to receive to activate the command mode. After blankly staring at it for a while, I finally realized that it showed the bit sequence, 1 followed by 0x01 which is the set board command followed by 0x02 which is the command parameter ( in this case 2 boards)But the bits had to be sent in Least Significant Bit First order.


After aimlessly looking for more specific documentation or code examples, I started poking around with Arduino’s SPI library and shiftOut() command and successfully came up with this:

#define CS 10
#define MISO 12
#define SCK 13

void setup()
  pinMode(CS, OUTPUT);
  pinMode(MISO, OUTPUT);
  pinMode(SCK, OUTPUT);
  digitalWrite(CS, LOW); 


void loop(){


Now the actual USB API is quite generic, and not very usefully in my purpose. The device just sits there doing nothing, waiting for a command. So you have to manually call for buttons status and manually set led colors by sending different commands and it again, every time it would return the buttons status. Now this created a great deal of latency.. I made a Processing sketch to drive the whole thing, but it is slow, by slow I mean SLOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOW…

The idea was to analize the receiving button status, send back a set color command to light up the pressed button, and then transform the parameters into MIDI data and forward it to the virtual MIDI port. Here is how all this worked out:

Part II:

2 comments for “SP Button Pad Controller ACT I (latency is a biatch)

  1. Thomas
    December 2, 2012 at 2:00 pm

    Great, I love you project. Would you be so kind and tell me where you get those Buttons. i love them really!

    • Tomash
      December 5, 2012 at 5:53 pm

      They are from Sparkfun

Leave a Reply

Your email address will not be published. Required fields are marked *