The B64 is an Arduino Shield that allows you to connect up to 64 buttons to your Arduino. You can use the B64 to make custom musical instruments, attach a lot of inputs, cool computer interfaces etc ...
The B64 has two eight pin connectors that make an eight row by eight column matrix for the total of 64 buttons. You do not have to format the button layout in a physical matrix nor do you have to use all of the 64 buttons. Unused buttons are simply ignored.
The B64 has its own microprocessor that takes care of all button scanning and decoding. Then simply sends messages to the Arduino that a particular button has been pressed or released.
The messages sent to the Arduino are very simple; when a button is pressed, the button number from 1 to 64 is sent with the MSB (MSB = Most significant bit) bit set. Meaning; A pressed button is from 129 to 192 (1 to 64 + 128) where a pressed button "1" is 129 and pressed button "64" is 192. When a button is released the shield sends just the button number 1 to 64, without the MSB bit set.
Here is what the message looks like; b'10000001' Button "1" has been pressed vs b'00000001' = Button "1" has been released. Where b'10000001' = 128 and b'00000001'= 1. (For more info on binary numbers: http://en.wikipedia.org/wiki/Binary_numeral_system )
There are two ways to interface the B64 with your Arduino Sketch. There is a shunt jumper on the shield that tells the B64 how it will communicate with the Arduino. The two modes are called, SPI and Serial.
The serial mode uses the Arduino's built in Serial pin (RX, digital pin 0). The B64 communicates at a fixed baud rate of 57600bps 8N1. Note: The B64 has a special feature that allows the B64 to remain seated on the Arduino, even while you are uploading your sketches. So as not to cause sketch upload errors, the B64 automatically senses when the Arduino is receiving a new sketch and disconnects itself from the serial pin. (The serial pin is used by the Arduino while a sketch is being uploaded) It automatically reconnects to the serial pin (if in serial mode) after the sketch is finished uploading. During the Arduino sketch upload, the busy LED will be on.
In SPI mode the B64 uses digital pins 2,3 and 4 for a custom synchronous data transfer. Note: this is not the a true SPI interface, it only uses three data lines; select, data in (out of shield, into Arduino) and clock. Also, this SPI will not work with the Arduino SPI library. Below you will find the simple custom SPI subroutine sketch that you can copy and paste into your own sketch.
One of the great features of the mode select jumper is that once a mode is selected, the pins for the non-used mode are electronically disconnected from the B64 shield, so your Arduino is free to use them.
Which mode is better? Here are some examples;
A. You want to use the B64 with the VoiceShield to make a sound effects box. In this case you would use serial mode. The VS, uses same digital pins as the SPI mode, so the B64 and the VS can not be used together in this mode. But, by using the Serial mode, the B64 can easily send messages to the VS.
B. Using the B64 as a MIDI controller with the Serial MIDI Converter software. Here you will be sending serial messages over USB from the Arduino to your computer to make music. Since the serial communication is already being used, you would choose SPI mode to send button press data to the Arduino and the serial port will still be free for the Arduino to communicate with the PC.
The overall way to determine which mode to use is like this; Use serial, unless your project uses the Arduino's serial receive pin. Using serial is easier and requires almost no code. Otherwise use the SPI mod. Make sure that your project does not use both the serial pin and digital pins 2,3 or 4.
Note: The mode is checked only once when the B64 is first powered on, so if you need to change the mode, remember to power cycle it.
Tools required: Soldering iron, solder and snips to trim the leads.
Other material required: Any number of buttons (from one to sixty-four), wire to go from button to button and from the shield to the rows and columns.
Recommended: Diodes 1N4148, one for each button.
Parts placement for the 64 Button Shield build is illustrated below. Important points are marked in red.
Use the illustration above to locate the resistor values.
Three values are used. 470 ohm, 1k ohm, 10k ohm.
470 ohm = Yellow, Purple, Brown
1k ohm = Brown, Black, Red
10k ohm = Brown, Black, Orange
Insert and solder the two small mustard colored 22pf capacitors and the silver 20 mhz crystal.
Insert and solder the two small blue 0.1uf capacitors.
Insert and solder the busy LED.
NOTE: The longer leg of the LED goes into the hole marked “+”.
Insert and solder the small diode.
NOTE: The stripe on the diode must match up with the stripe on the B64 PCB.
Insert and solder the two IC Sockets.
NOTE: The notch on U1 for the PIC is facing down, and the notch for U2 the port expander, is facing up.
OPTION: The sockets are optional.
Insert and solder the four extra-long stackable pin headers.
OPTION: If in your project the B64 is going to be stacked on top, then regular male pin headers can be used instead. (And you can keep the extra-long included stackable headers for another project.)
The connection to the buttons is made with the 16 pins on the right side of the B64 that are broken into two sets, one for the 8 rows and the other for the 8 columns. No hardware is supplied with the shield for the rows and columns connector, but there are plenty of possibilities. Here are a few suggestions;
Connector for a ribbon cable. [Only recommended for top shield stacking]
90° Female connector (Can be used with male jumper wires).
90° Male connector (Could be used with female jumper wires, or a ribbon cable).
Vertical female header. (Can be used with male jumper wires).
[Only recommended for top shield stacking]
Hardwired. Inexpensive and easy, but harder to make future changes.
The B64 does all of the button decoding for you. What is needed to use the B64 is a bunch of N.O. buttons. (Normally open buttons) A N.O. button is simply a button that, when not pressed, does not complete the circuit, or in other words is off.
The best way to wire up your buttons is to connect the column pin on the B64 with one side of up to eight buttons and the other side of these buttons through a diode to one common row pin. Use one of the B64 column pins per eight buttons connected to a common row pin. If you don't plan on using 64 buttons then simply leave the unused pins disconnected. Also, you do not have to populate each row with eight buttons before starting a new row or column.
An easier, but less flexible way to connect the buttons to the B64 is to connect one side of each of the buttons to the rows connectors and the other side to the columns connectors. Note: this configuration will work for single and some multiple press button sensing, but can produce some false buttons presses.
In this project, the rows and columns were wired up without diodes.
NOTE: This will work well for “one at a time” button press decoding, but in some cases will give erroneous results when pressing more than two buttons at the same time. To avoid this, use diodes.
Same project, but updated with diodes to replace the column wires.
(Using the diodes in this case is actually easier than using wires. The diode leads are stiff, and pre-cut unlike the wires.)
There are two main types of Arduino sketches required to use the B64.
To use the B64 in SPI mode, there are three main pieces of code that your sketch must include. A variable to hold the button press, an interrupt attach in the setup and void to be called when the B64 triggers the interrupt. Interrupts are used because of their speed. An interrupt will interrupt the Arduino from doing something and have it deal with the incoming data from the B64 right away. This speed helps eliminate the possibility of missing button presses. Once finished with the incoming data, the Arduino goes back to were it was interrupted from.
See the demo sketches for more info.
For the serial mode there is virtually no special B64 code required. Simply have your Arduino handle incoming serial data. The B64’s baud rate is fixed at 57600bps.
See the demo sketches for more info.
Description: This sketch demonstrates and contains the code required to use the B64 in SPI mode. With the Arduino connected to your computer and the B64 stacked on top. This sketch sends serial data with the button press info to your computer. This data is viewable in a terminal software or with the Arduino IDE ’s serial monitor.
Description: This sketch demonstrates using the B64 in SPI mode as a MIDI controller. With the Arduino connected to your computer and the B64 stacked on top, this sketch sends serial data in three byte MIDI packets to your computer. By using the Serial MIDI Converter software, the buttons can play notes in music software such as Apple's GarageBand, Ableton Live etc.
Trying to debug your project, want to know more about how the 64 Button Shield works? Below you will find images of the board and the schematic.
Copyright SpikenzieLabs 2019