This page shows instructions for version 2.1 of the robotic xylophone which uses an SD Card for the data storage.  Instructions for version 2.0, using SPI Flash, are here.

Once the enclosure is built, and the xylophone and mallet assembly are mounted, the electronics are assembled as follows:

Step 1: Label four of the Arduino Uno’s with the numbers 0, 1, 2, and 3 as shown below.  These will be referred to as “Slave” Arduino boards, because they will receive commands from the “Master” Arduino.


Step 2: Download the program “L293DBoardSerial.ino” into each of these labeled Arduino’s.  Prior to downloading, change the #define DEVICE_ADDRESS to whatever is labeled on the Arduino.  In short, this program controls the L293D Motor Driver board, and it fires the solenoids according to Serial messages that it recieves.  See the Motor Driver Tutorial and Software page for more details on this program.  This program is available on Github.

Slave Program

Step 3: Secure the four labeled Arduino boards to the base as shown below.  Use four #4 x 3/8″ wood screws for each Arduino board.


Step 4: Using 22 AWG hook-up wire, attach the Serial TX/RX pins of the Arduino boards as shown below:

  • Slave 1 Pin 0 (RX) to Open Wire
  • Slave 1 Pin 1 (TX) to Slave 3 Pin 0 (RX)
  • Slave 3 Pin 1 (TX) to Slave 2 Pin 0 (RX)
  • Slave 2 Pin 1 (TX) to Slave 0 Pin 0 (RX)
  • Slave 0 Pin 1 (TX) to Open Wire

The Open Wires will be attached to the TX/RX pins of the fifth (Master) Arduino Uno at a later step.


This arrangement works because the “L293DBoardSerial” program, which is running inside each of the Slave Arduino boards, always transmits the same serial messages that it receives.  So when the Master Arduino sends a command via the Serial TX pin, this command gets passed onto each of the Slave Arduino boards.  See the Motor Driver Tutorial page for more details on this architecture.

Prior to running this serial communication wire, you will need to drill 1/8″ diameter holes in the base, and screw in a #6-32 x 3/4″ machine screw at the places shown in the pictures.  The 22-AWG hook-up wire can be twisted around the machine screw in order to secure it better.


Step 5: Using a Flush Diagonal Wire Cutter, remove pins 0 and 1 from all of the L293D Motor Driver Shields.


Step 6: Place the four Motor Driver Shields on top of the four Slave Arduinos.  Make sure that the all of the pins on the Shields are inserted into the appropriate female header pins on the Arduinos.


Step 7: Use 22 AWG hook-up wire to connect the +M and GND screw terminals of all of the Motor Driver Shields.  This will provide the power for the solenoids.  Leave extra Black (GND) and White (+12V) wires which will later be connected to VIN and GND pins on the Master Arduino.  From the last Shield, wire the 2.1mm DC Barrel Jack.


Here is a closer view of the back and front of the base with the power wires run.


Step 8: Wire the solenoids into the Motor Driver Shields.  Note that each shield can drive up to 8 solenoids.  One wire from each solenoid needs to go to the GND terminal.  There are only two of these on each shield, so up to four of these wires may need to be twisted together.  The other wire from the Solenoid goes to the appropriate terminal that will drive a current (M1A, M1B, M2A, M2B, M3A, M3B, M4A, or M4B).  See the Motor Driver Tutorial for more details.  Make note of which solenoid/note (e.g. G3, G#3, A3, etc.) is wired into which board and which terminal (e.g. Slave 0 terminal M1A).



The entire xylophone assembly, with the motor driver boards wired to the solenoids, looks like below.


Step 9: Connect the final Arduino Uno to a computer via USB and load the “XylophoneSD.ino” program.  Prior to loading the program, you will need to modify settings related to the hardware (e.g. number of notes, highest/lowest note, and mapping of notes to motor driver board terminals).  Refer to the code comments and Software page for details.  This will be the Master Arduino because it will control the other four Slave Arduinos.


Step 10: Connect the +12V (White) and GND (Black) wires to the VIN and GND terminals of the Master Arduino Uno.  Connect Slave 1 Pin 0 (RX) to the Master Arduino Pin 1 (TX).  Connect Slave 0 Pin 1 (TX) to the Master Arduino Pin 0 (RX).


Step 11: Connect the LCD and Rotary Encoder to the Master Ardunio.  Pin connections are as shown below.


Step 12: Connect the 12V LED Power Supply to the DC Power Jack.  If everything is powered correctly, you should see green LED’s on each of the Motor Driver Boards come on.  You should also see the Master Arduino Uno and LCD powered up, with the LCD showing the “Hardware Test” menu.  If the LCD is powered, but no text is shown (first and third lines are solid boxes), then most likely the I2C address needs to be changed.  See the code comments for details.


If the Rotary Encoder is wired correctly, you should be able to turn it to select an item from the menu.  Make sure that you can move the cursor both up and down.  You should be able to press down on the Rotary Encoder to select the current menu option.  If any of this doesn’t work, make sure that the terminals on the Rotary Encoder are wired to the correct Arduino pins.

Step 13: Use the “Solenoid/Note Test” and “Chromatic Scale” options of the “Hardware Test” menu to make sure that all of the solenoids work correctly, and that they fire with the correct note.  The “Solenoid/Note Test” option allows one to test a single solenoid.  The Rotary Encoder is used to select which Solenoid/Note to test.  The “Chromatic Scale” option will fire all solenoids to play all notes, in order from the lowest note to the highest note.  See pictures and videos below.

If any of this does not work as expected, the most likely cause is that either the solenoid is not wired into the motor driver shield correctly, or the Note Map definition within the Arduino program does not match how the solenoids are wired into the shields.



When you are satisfied that all notes work correctly, disconnect the LCD and Rotary Encoder and move on to the Final Assembly.

Next: Final Assembly