Introduction: Hacking a Sound Recorder

Picture of Hacking a Sound Recorder

The following information is a single lesson in a larger project. Find more great projects here.

Return to Previous Lesson: Writing the Code

Lesson Overview:

Now we'll hack some electronics!

Step 1: Introduction

As we mentioned at the beginning of the project, controlling recorded sound is a good example of how to hack a device using a single button.

Imagine you have a digital sound recording device with a playback button - or maybe you actually do have one! The following lesson will challenge you to program the Arduino to control this kind of device.

  1. Continue to the next step.

Step 2: A New Challenge

Suppose you have recored a sound on a digital recorder. Maybe it's your own voice, your cat or dog, or clanking pots and pans in the kitchen. You'll use the Arduino and optocoupler to hack the playback button, so the Arduino controls when and how long your recorded sound will play.

How would you modify the LED blink code so the project does the following:

Briefly press the playback button, then release

Play 20 seconds of the recorded audio

Repeat

(see the hint, then move onto the next step for our version of the code.)

  1. Try modifying the code to emulate the audio playback scenario.

  2. Continue to the next step.

  3. Stuck? HINT: All you need to do is modify the times on both delay() functions.

Step 3: Audio Playback Code.

Picture of Audio Playback Code.

In our version of the audio playback code, we didn't change the header or setup() section at all. We just changed the loop() function:

  1. Here is our sample code: void loop() { digitalWrite(optoPin, HIGH); delay(15); digitalWrite(optoPin, LOW); delay(2100); }

  2. When the loop starts, the control circuit holds down the playback button very briefly (only 15 milliseconds). Then the button is released and the audio is allowed to play for 21 seconds. Then the loop starts over, and the program presses the button again.

  3. Continue to the next step.

Step 4: Creating Custom Sounds

With this project, you could try experimenting with different sounds and durations of toggling the playback using the delay() function in your program.

Below are a couple of scenarios that you can try or discuss with your friends.

  1. If you trigger the switch while a sound is playing, it will stop. How can you take advantage of this to create a unique set of sounds?

  2. How could you incorporate the inputs from earlier projects (like the photoresistor or potentiometer) to trigger these sounds?

  3. Continue to the next step.

Step 5: Think About It...

This technique for controlling an electronic device with an optocoupler can be used in many other devices.

  1. What other battery powered things do you have around your home or classroom that could be controlled by an Arduino?

  2. Are there any output components in the circuit simulator that you would like to control this way?

  3. Continue to the next step.

Step 6: Review

Integrated circuits (ICs) are in virtually every electronic device - optocouplers are only one example. In fact, the large 28 pin chip on your Arduino is an IC that houses the brains of the board. There are other ICs that support this one with communication and power.

The optocoupler and main chip on the Arduino have the shape of a Dual In-Line Package (DIP) chip. DIP chips are the kind that most hobbyists use because they easily plug into a breadboard an don't have to be soldered!

Congratulations, you have completed this project!

Check out other great projects here.

Comments

About This Instructable

458views

3favorites

License:

Bio: Circuit lessons for Tinkercad Circuits!
More by circuits:IntroductionProject 15: Hacking ButtonsProject 14: Tweak the Arduino Logo
Add instructable to: