How can I control sounds using a microcontroller?
- How do people design instruments to control sound?
- How do people control sound with instruments and interfaces?
- How can I control sounds using a microcontroller?
Step 1. Take a look at some ways people interact with sensors to control sound
In this project we are going to make a button (sensor) using aluminum foil to sense touch
To use buttons (sensors) in projects, we need to know about inputs and outputs.
Output – causes something to happen in your local environment.
Input – read or senses something from the local environment
- Categorize the following as outputs or inputs:
- Photo sensor
Interested in finding out more about inputs and outputs?
There are two parts to building your interface:
- building the circuit
- coding the microcontroller
Step 2: Building the Circuit
You will need all of the materials from XP 5C1 along with the following materials:
- alligator clips
- aluminum foil
- (optional) arcade button or other type of electronic button
Step 3. Add your button
- Start with two small pieces of aluminum foil.
- One piece will be the positive side of your “button”
- The other piece will be the negative side of your “button”
- Attach one alligator clip to a piece of foil
- Clip the other end of the alligator clip to a wire in pin 5 on the microcontroller
- Using a second alligator wire, attach one end to the other piece of foil
- Clip the other end of the alligator clip to a wire in the GND pin on the microcontroller
You created a circuit for your interface!
Step 4: Next, we’ll upload an Arduino sketch that uses an output (the speaker) and an input (the foil button).
Coding The Microcontroller
- Download the file music_inputs_outputs
- Open the music_inputs_outputs file in your Arduino IDE
- Look at the void setup () section (see the image below)
- In the setup section, we declare that the button (pin 5 since that is where we inserted the wire) is an input.
- We then set the button to HIGH
- Now, look at the void loop section (See image below)
- Since we set the button to HIGH in our setup, the loop tells the speaker to play a tone if the sensorValue of the button is LOW
- Otherwise, or “else” make no tone
- Upload the code to your microcontroller
You have now built your interface. It’s time to play it!
- Touch the two pieces of foil together
- You should hear a tone.
Share What you Learned
If you are using the LRNG platform:
- Go back, find out what to submit, and complete the XP
- If you want, you can then learn even more with the optional “Go Further!” activities below
If you are not using the LRNG platform:
- Continue below and share with your teacher or organization:
Sharing What You Learned
- Upload a video of you making a sound with your microcontroller
- Show your circuit, button, and code sketch in the video
Curious about learning more?
Go Further! (optional) Explore how to develop your instrument with the code or interface
Return to the XP How can I create instruments and interfaces with microcontrollers? (continue to the next XP in the mini-playlist)