Skip to Content

How do I program my instrument or interface to make sound?

Think About

  • How can I make sound with a microcontroller?
  • What do I want my instrument to do?

Get Started

Step 1. Get a sketch to use

  1. Download the following Arduino file called music_output 
  • The music_output file is called a sketch.
  • A sketch is an Arduino program that you use to program your microcontroller. 
  • When you open the music_output sketch, it looks like this:

music_output_ss-noarrow

We’ll talk more about the sketch and how it works in the next part, but for now, let’s send this sketch to your microcontroller.

  1. Plug your microcontroller into your computer’s USB port. (We did this in the last XP. Refer back to it for photo)

Step 2. Watch the following video to learn how to program a microcontroller to make sound. Directions are also available below in text:

  1. Go to the tools menu at the top of your screen to select the Arduino board you’re using. I’m using an Arduino Uno, so that’s what you’ll see in these images.

tools_ss

  1. Go to tools menu again to select the port you’re using. See the image below:
    1. On a Mac, your will choose a port that has usb in the name. The port name won’t be the same as in this image.
    2. On a Windows computer, your port will be COM followed by a number.

port_ss

  1. At the top of your sketch, click on the arrow to upload (or send) the code to the microcontroller:

music_output_ss

Step 3. Check to see if it worked

You should hear a three note melody.

Do you hear it? 

If you don’t hear anything, check your wiring and make sure your circuit is set up correctly.

Is the red wire or positive side of the piezo buzzer connected to pin 7?

[NOTE: If you receive an error message please, have your teacher either take a screen shot or copy and paste the error message and send it to the playtest coordinator]

If you hear the melody, you programmed your microcontroller to make sound!

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 your circuit and code working 
  • You should be able to play the 3 note melody to someone

If you are not using the LRNG platform:

  • Continue below and share with your teacher or organization:

Sharing What You Learned

  • Upload a photo or short video of your Arduino making sound.

Next Steps

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