Skip to Content

How can I use the interface I built to play melodies that I create?

In addition to programming melodies with numbers, you can also use note names.

Think About

  • How can I make sound with a microcontroller?
  • How can I program melodies in the Arduino IDE?
  • What do I want my instrument to do?

Get Started

Step 1: Watch this video that shows you how to program music with note names in your Arduino IDE. Directions are also available below as text:

In this sketch, I’ve pasted in some variables that are helpful to people who are used to thinking about notes using letter names: A, B, C, D, E, F, G.

  1. Download the note name sketch

The new variables are named after the letter names (A, B, C, D, E, F, G).

I looked up the frequencies measured in hertz of these notes online and typed in them in here.

  1. Now in the void loop section, try typing some letter names of the notes (you don’t need to use any numbers).

music_output_with_note_names-ss

Remember to upload your code to your microcontroller every time you make a change to the sketch.

Share What you Learned

If you are using the LRNG platform:

  • You do not need to submit anything for this XP
  • You should be able to show someone the code playing your melody with note names

If you are not using the LRNG platform:

  • Continue below and share with your teacher or organization:

Sharing What You Learned

  • Upload a recording or short video of your microcontroller playing the melody you coded and uploaded to the microcontroller.

Next Steps

Return to the XP How can I create instruments and interfaces with microcontrollers? (continue to the next XP in the mini-playlist)