1 Arduino Uno (We will be using the SparkFun RedBoard Inventor's Kit)
Computer with Internet Access
1 USB A-to-B Cable
1 Breadboard
1 Piezo Buzzer/Speaker
2 Jumper Wires
An Arduino is one of the most popular open-source physical programmable circuits (often referred to as a microcontroller) for use in a wide range of projects both physical and virtual. The Arduino board is coupled with a piece of software, known as the IDE (Integrated Development Environment) which runs on your computer and allows programs to be written and uploaded via your computer to the physical Arduino board. This IDE runs on a simplified version of C++, which makes learning programming easier and allows programming knowledge to be accessible to students everywhere.
Starting with their first Arduino board in 2005, over 26 different board types (most notably Arduino Uno, Arduino Due, Arduino Mega, and Arduino Leonardo) have been created with the intention of making prototyping projects in the physical world much simpler. Today we will be using the SparkFun RedBoard, which is an Arduino Uno knockoff from SparkFun.
Along with the Arduino, our main sound producing component is the Piezo buzzer. A Piezo buzzer, or Piezoelectric speaker, is a loudspeaker that uses the Piezoelectric effect to create sound. This effect shows how objects, often made of ceramic materials, will bend or resonate when a voltage is applied. A Piezo buzzer uses this phenomenon to resonate at auditory frequencies to make a buzzing noise of differing tones. By adding tones together in a sequence, a melody can be created.
Piezoelectric Effect - the ability of certain materials to generate an electric charge in response to applied mechanical stress, and vice versa.
Piezo Buzzer (Piezoelectric Speaker) - a type of electronic device that is used to produce a tone, alarm or sound through the Piezoelectric effect.
Arduino (board) - open-source physical programmable circuits (often referred to as a microcontroller) for use in a wide range of projects both physical and virtual.
Microcontroller - a compact integrated circuit designed to govern a specific operation in an embedded system. Can sometimes act as a miniature computer with limited output capabilities.
Arduino IDE (software) - a cross-platform application (for Windows, macOS, Linux) that is written in functions from C and C++. It is used to write and upload programs to Arduino compatible boards.
Breadboard - a board for making an experimental model of an electric circuit.
C++ - a high-level, general-purpose programming language.
Compile - convert (a program) into a machine-code or lower-level form in which the program can be executed. The program will also be checked for bugs and errors.
For this project, you will need 1 SparkFun Redboard Inventor's kit, which includes all necessary components.
If this kit is unavailable, you can buy all of the materials separately as listed above.
Although jumper wire colors are not important in making simple circuits, it is good practice for major projects to follow color codes: red for positive, black for negative, and other colors to denote where data is flowing to and from. If you would like to follow the color conventions, the number of each colored wire goes as follows: 1 black wire and 1 red wire.
Go to https://www.arduino.cc/en/Main/Software and install the Arduino IDE software for use on your computer. If you do not have an Arduino or the Arduino IDE does not work on your device, you can follow along digitally by creating an Arduino circuit at https://www.tinkercad.com/circuits.
Once the IDE is installed, you will need to connect your Arduino to your computer. To do this, plug one end of the USB cable to the Arduino Uno and then the other end of the USB to your computer’s USB port.
Once the board is plugged in, you will need to open the IDE and click on Tools > Board > Arduino Uno to select the board.
Next, you have to tell the Arduino which port you are using on your computer. To select the port, go to Tools > Port and then select the port that says Arduino.
Plug your black wire into one of the ground (GND) ports on the Arduino board. Plug the other side of the wire into the A15 port as seen in the picture to the left.
Plug one leg of the Piezo buzzer into the E15 port on your breadboard. Make sure the other leg plugs into somewhere on the E column and make note of which port for use in the next step as most buzzers have short legs and it may be confusing if your buzzer cannot reach to the port I suggest.
Plug your red wire into the digital 8 port on the Arduino board. Plug the other side of the wire into the A column matching the number your opposite leg is placed in, as noted from the previous step.
Download the sample code here: https://tinyurl.com/rc6mjdr
Click the checkmark icon to compile your sketch, and the right arrow icon to upload to your Arduino board. As soon as you upload the code, the sample tones will begin to play.
Within the code, each note is previously defined as a numerical code corresponding to the electrical tone the buzzer must make to create the note. Within the melody[] array variable, you can determine the order these notes are played in. Within the noteDurations[] array variable, you can determine the length each note is played for. These two arrays MUST be of equal length or the buzzer will either cut your melody short (if melody[] exceeds noteDurations[]) or play the last provided note for each additional new note (if noteDurations[] exceeds melody[]).
NoteDurations[] is measured in the length of each note, such as 4 for a quarter note, 8 for an eighth note, and so on.
A few melodies will be provided below for you to test out. If you would like to create your own melody, it's as easy as reading sheet music and placing it within the code.
*Note, some of these programs have different pin-outs. If music does not play, locate which pin data is flowing through (or simply move your red wire from pin 8 to all other numbers to test).