The First Thing You’ll Need…






I used the following Radioshack parts to make the xylophone:
(x1) Radioshack #276-127 Arduino Mega 2560
(Radioshack #273-073) Piezo Element (x12)
(x12)
Radioshack #271-1356 1M Ohm resistors
(x1)
Radioshack #278-1221 single core wire
(x1)
Radioshack #276-170 Printed Circuit Board
(x1)
Radioshack #26-714 USB 2.0 Cord
Electrical Tape (Radioshack #64-2373) (miscellaneous)
Heat shrink (Radioshack #55048444) is a miscellaneous item.
The xylophone’s housing was simple to construct.
I made use of:
Tools:
scissors with a laser cutter
tiny flat head screwdriver cotton swabs




Step 2: Solder Longer Leads After Freeing the Piezos.
I utilised piezo components to detect when each note on the xylophone was struck for this project.
Vibration or a knock is detected by these piezos.
The components are frequently packaged in a housing to keep the disc from being twisted or damaged, but I needed to remove them from their plastic for this project.
I unfastened the bottom of the shell by gently pressing around the edges with my fingertips, you could hear the adhesive snap apart from the plastic.
I carefully inserted a precision flat-head screw driver and carefully popped the case’s bottom off.
After that, the piezo element may be removed from the housing’s outside.
I could have up to 16 analogue inputs or 16 Piezos because I’m using an Arduino Mega Board.
I opted to utilise 12 piezos since I only wanted an octave and a half of notes.
I attached longer wires to each piezo element once they were freed from their case to prepare them for insertion into the xylophone.
I covered my solder spots with heat shrink or electrical tape when I finished soldering longer leads onto each piezo.


Step 3: The Bars and Accommodations
I utilised CorelDraw to create vector files that would be used to guide the laser cutter in cutting the xylophone’s housing and bars.
Each of the acrylic bars measured 10×2 inches.
Each bar includes two holes in it that will guide a machine screw through the bar and secure it to the wooden housing’s top panel.
10.5x30x3 inches is the size of the wooden enclosure I created.
It takes the shape of a shallow box that houses the electronics.
I secured all of the corners using woodglue and a cotton swab, then waited 24 hours for it to set before sanding down all of the edges.
This stage includes the CorelDraw file for the base housing.




Attach the Piezos to the Bars in Step 4.
The Piezo wires were put through the housing’s central holes.
Then I used 2 inch blue masking tape to stick the piezo element to each acrylic bar, centering it on the bar.




Attach the Bars to the Top Panel in Step 5.
I used 1 1/2 cups “To fasten the bars to the wooden panelling, machine screws and nuts were employed.
I chose to use vinyl tubing as a shock absorber on each machine screw to prevent excessive shaking or vibration on each bar.
I utilised 24 machine screws and nuts, as well as 24 3/4″ machine screws and nuts, to make 12 bars “vinyl tubing in various lengths Insert the machine screw into the bar, then into the vinyl, then into the panelling.
I was able to twist on the nut to firmly attach it to the panel once the screw was through the panel.
To minimise stressing the panelling or the bar, all of them should only be finger-tight.






Step 6: Construct the Circuit
I added a 1-megohm resistor in parallel to the piezo element before connecting it to the Arduino to restrict the voltage and current produced by the piezo and to safeguard the Arduino’s analogue input ports.
I designated which piezo goes to each analogue input port on the Arduino with a permanent marker on the PCB.
On the reverse of the top wooden panel, I made the same marks.
I attached a tiny jumper wire from one end of the resistor to the longest rail on the PCB and identified it as my ground rail after soldering the resistors in place.
Next, I connected the ground wires of all the piezos into position, aligning them with the same end of each grounded resistor.
The piezos’ positive leads are attached to the same rail as the resistors’ other ends.
I cut 12 pieces of green wire to use as my Arduino’s “signal wire.”
Each signal wire is connected to the piezo’s positive resistance rail.



Connecting to the Arduino in Step 7
I used blue masking tape to identify all of the signal lines and the ground wire that ran from the PCB, noting which port each wire was assigned to.
All of the designated single core wire was then inserted into the Arduino’s matching ports.
Ground all remaining Analog ports!
Otherwise, it will interfere with the Arduino’s serial output.
Four black wires were routed straight from the PCB’s ground rail to the Mega board’s open analogue ports.
A12, A13, A14, and A15 are the letters that make up the letters A12, A13, A14, and A15.
After you’ve finished your circuit, use the Arduino Developing Environment to load the xylophone software, or sketch, onto the Arduino board.
Here’s the design I came up with.
Code :
//*******************************************************************************************************************
// User settable variables
//*******************************************************************************************************************
int pinRead;
char pinAssignments[6] ={
'A0','A1','A2','A3','A4','A5','A6','A7','A8','A9','A10','A11'};
byte PadNote[16] = {
57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72}; // MIDI notes from 0 to 127 (Mid C = 60)
int PadCutOff[16] =
{
400,400,200,800,400,400,400,400,400,400,400,400,400,400,400,400}; // Minimum Analog value to cause a drum hit
int MaxPlayTime[16] = {
90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90}; // Cycles before a 2nd hit is allowed
#define midichannel 1; // MIDI channel from 0 to 15 (+1 in "real world")
boolean VelocityFlag = true; // Velocity ON (true) or OFF (false)
//*******************************************************************************************************************
// Internal Use Variables
//*******************************************************************************************************************
boolean activePad[16] = {
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; // Array of flags of pad currently playing
int PinPlayTime[16] = {
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; // Counter since pad started to play
byte status1;
int pin = 0;
int hitavg = 0;
//*******************************************************************************************************************
// Setup
//*******************************************************************************************************************
void setup()
{
Serial.begin(57600); // connect to the serial port 115200
}
//*******************************************************************************************************************
// Main Program
//*******************************************************************************************************************
void loop()
{
for(int pin=0; pin < 16; pin++) //
{
//int pin = 3;
// for (pinRead=0; pinRead < 16, pin++){
hitavg = analogRead(pinAssignments[pin]);
//Serial.println(hitavg);
// read the input pin
if((hitavg > PadCutOff[pin]))
{
if((activePad[pin] == false))
{
if(VelocityFlag == true)
{
// hitavg = 127 / ((1023 - PadCutOff[pin]) / (hitavg - PadCutOff[pin])); // With full range (Too sensitive ?)
hitavg = (hitavg / 8) -1 ; // Upper range
}
else
{
hitavg = 127;
}
MIDI_TX(144,PadNote[pin],hitavg); //note on
PinPlayTime[pin] = 0;
activePad[pin] = true;
}
else
{
PinPlayTime[pin] = PinPlayTime[pin] + 1;
}
}
else if((activePad[pin] == true))
{
PinPlayTime[pin] = PinPlayTime[pin] + 1;
if(PinPlayTime[pin] > MaxPlayTime[pin])
{
activePad[pin] = false;
MIDI_TX(144,PadNote[pin],0);
}
}
}
}
//*******************************************************************************************************************
// Transmit MIDI Message
//*******************************************************************************************************************
void MIDI_TX(byte MESSAGE, byte PITCH, byte VELOCITY)
{
status1 = MESSAGE + midichannel;
Serial.write(status1);
Serial.write(PITCH);
Serial.write(VELOCITY);
}



Step 8: Communication and Power
The Arduino is fuelled by a USB port that also serves as a communication interface.
A USB cable was run through the xylophone’s enclosure.
I was able to hide most of the USB chord in the housing by drilling a tiny hole large enough for the ends of the cable.
To hold my mallots, I drilled a second hole.
Step 9: Converting from Serial to Midi
I used software called Hairless to connect the xylophone to my computer.
It transforms the Arduino’s serial output signal to a MIDI signal that can be read and recorded by apps like GarageBand, Logic, and Ableton.
Before attempting to import MIDI data from the xylophone, make sure the bridge is up and functioning.
Note: If you’re trying to update the programme on the Arduino board, turn off the bridge.
You can’t use the Arduino software to connect with the board while the bridge is operating.

Step ten is to jam it!
You can play the xylophone like drums after you’re up and running.
Make a beat track on your computer.
Then switch to a bass synth on the MIDI instrument and record a rhythm track.
Finally, convert it to a xylophone and compose a melody track for the greatest song ever written.
Instead of winning something using a lie, it is better to lose something by speaking the truth
KP
“If you want more customers for the growth of your business, you should be transparent to them for everything, this way you can earn their trust.” – KP
Helping Hands.
I loved this 🙂