A Musical Arduino Project
- Harry

- 3 days ago
- 3 min read
In this project you will use an Arduino to create a little musical instrument that can play 3 notes with the ability to move up or down an octave. The project is simple and easy to follow, you don’t need to know how to code or how to do electronics, I have taken care of all that for you. Simply follow the steps and enjoy your own creation.
What You Need
First of all, let’s make sure you have the right kit, for this project you need:
1x Ardunio Uno R3 (or any Ardunio with a PWM pin)
1x Breadboard
1x Piezo electric buzzer
5x Push buttons
5x 10K Ohm resistors
1x 220 Ohm resistor (optional)
Some jumper wires
A USB cable for your Arduino
A laptop/PC
These components are fairly basic and will likely come with any starter kit you get with a dev board.
In terms of software, you will need to download the Arduino IDE if you have not already, it can be downloaded here if you do not have it.
Building the Electronics
Let us begin with the hardware, you can arrange your buttons and buzzer however you want but make sure your resistors and jumper wires are the same as in this diagram otherwise it will not work properly.
This is how you need to arrange your components:

This might look complicated, but I will break it down for you. Also, all the buttons are the same so once you have done one you know how to do them all.
Power and Ground
First place a jumper cable from the 3.3v and GND pin to the ground and power rails on your breadboard like this.

Buttons
Next place a button, jumper wire, and a 10k Ohm resistor like this.

Then repeat that arrangement again to make a set of 3 buttons and a set of 2, make sure to separate them enough so you have room to press one at a time with your finger.

Buzzer
Now place your buzzer and the 220 Ohm resistor connected to ground.

The 220 Ohm resistor is optional. I use one to lower the volume of the buzzer, you might want it to be louder or quieter so just use a smaller or larger resistor to adjust the volume. Or, if you are feeling jazzy you can use a variable resistor to control the volume dynamically.
Jumper Wires
Finally add the jumper wires. This step is important so make sure each wire goes to the correct pin. The buttons should be wired up so that each button goes into pin 2, 3, 5, 6, and 7 from left to right.

The buzzer wire should run from its positive terminal to pin 9.

You should have a breadboard full of buttons and a buzzer that looks like this.

All that is left is to program the Arduino and you will have your own music player!
Programming the Arduino
If you do not have the Arduino IDE installed, you should do it now using the link at the top of this page.
Open the IDE to a new sketch and delete all the code that appears by default, then copy and paste the code from the above text document into the blank sketch.
Connect your Arduino to your laptop or PC and press the upload button in the IDE.
If you did everything correctly, you should be able to play music using the 3 buttons on the right of your breadboard! You can move up an octave by pressing and holding the right button of the 2 on the left or down an octave with the button furthest to the left.
If you want to change which 3 musical notes can be played simply change the notes in this part of the code.

Enjoy your Creation
Congratulations! You have made a musical instrument using an Arduino. Time to see what music can you play.

Comments