Champaign-Urbana Community Fab Lab
Champaign-Urbana Community Fab Lab

Iteration Assignment – Edbert Linardi

For this week’s iteration assignment, I chose to redo the Arduino sensor project. Last time, I only managed to use the rotary sensor to set the LED’s brightness. This time, I wanted to make a mini music player, using the buzzer sensor and the rotary sensor. My idea was to use the rotary sensor to choose the song. It is inspired by music toys for the little kids. This is the first time that I use Arduino’s buzzer output. I was excited to learn how to use this buzzer.

First, I had to produce sounds. I was confused about setting the tone and frequency. I only could produce three tones, which are low, medium and high. It sounds like this:

Then, after spending quite some time researching on the internet, I learned that I could set many different frequencies. I created an array of frequencies for all chords. So, I looked for the chord for a very popular song, Twinkle Twinkle Little Star. I put the chord frequencies into an array, and created a loop to iterate through the entire array. It looks like this:

It is not perfect, since it’s only a buzzer, which has a very limited range of frequencies. Then, I looked for the chord for another song, which is London Bridge. After being able to produce the two songs, I start plugging the Rotary sensor into the Arduino. At first, I couldn’t manage to set the value of the rotary sensor to choose the song, since the Arduino was stuck in the loop and did not care about the rotary sensor’s value. My solution was to create a function that listens to the rotary sensor, while playing the song. It was a success. After rotating the sensor, the song was changed.

Here is the final result:

Finally, I learned a lot about Arduino by doing this project. For example, I learned how the main loop in Arduino works, and global variable is very useful in Arduino. In my CS class, I avoid using global variable, since it is dangerous. Moreover, I am satisfied that the arduino works as I wished. I met my goal, which was to create a mini music player with rotary sensor to choose the song. However, the only thing that I disliked was that sometimes the sensor did not work. I need to rotate several times before the music changes. I believe it is a synchronization problem in the Arduino.

In the future, I want to make a real music player with Arduino, using a real speaker and more complicated songs.


Here is the storyboard of my project. It tells about the arduino which plays music, and can be controlled with a certain controller. In my project, the controller is a rotary switch.