
This will show you information about what is going on in the sketch. You can enable debugging by uncommenting the line #define DEBUG and open the Arduino serial monitor with speed 115200. If the controls are confusing, just play with it for a while until you get the hang of it.

Go ahead and record a third track and loop them all together. They will both loop and will mix together. Now tap the track button for the other track you recorded. Hold the loop button and tap the track button for your new track. Now hold the record button and hold a new track button (like track 1) to record onto that track. Enable the input passthrough by tapping the record button. To stop the looping of the track, tap the track button. Adjust the loop delay by adjusting the track’s potentiometer. Now you can release the loop and track button, but the track will continue to play in a loop. To cause the track to play in a loop, first press and hold the loop button, then press the track button. To play the track (just once), press the track button. Release the track button when done recording, or if you exhaust the memory size for that track, the output will stop. Now press and hold the record button down, then hold down a track button to record the track. To record a track, first enable the audio passthrough so you can hear the audio signal. That is, when the sketch starts, the input is passed through to the output so you can hear it, but you can enable/disable the passthrough by tapping the record button. When the record button is tapped (pressed and released), it toggles the “passthrough” mode for the input. You can build it on a breadboard if you want: A delay of 0 just plays the sample over and over again with no delay.įor this project, I used the DJ Shield because it provides all the buttons and pots.

The loop delay is the time delay before playing the sample again. You can adjust the loop delay by using a potentiometer associated with the track. With this sketch you can record 3 different tracks and play each of them back in a loop. Load the Audio Hacker example sketch File->Examples->Audio Hacker->Looper. It demonstrates how audio samples can be combined so that they are mixed at the output. Now we call them “tracks” instead of samples. note durations: 8 = quarter note, 4 = 8th note, etc.This Audio Hacker project is similar to the Four-Sample 12-bit Sampler project but now we can loop the samples and mix them together. * The song is played on the speaker connected to pin 3 and GND. * This program will play the theme song of the Malayalam movie You can modify those and create any song according to your wish!Ĭonnecting the Arduino, Speaker, and Power Connect a speaker or a piezo buzzer to the Arduino with one wire to the Digital pin 3 and the other one to the ground of the Arduino. The note and its corresponding duration is what is there in melody and noteDurations respectively. Higher value gives longer duration notes. Here 8 = quarter note, 4 = 8th note, etc. Then I wrote noteDurations according to the length of each music note. I wrote down the musical notes of this song first and then wrote the melody array with that. I found out the notes of this song with my guitar. The first array contains the notes and the second array contains its corresponding durations. It is similar to how ringtones were written in old Nokia cell phones. How I made melody and noteDurations of this song: If you take a look at the program, you can find two int arrays: melody and noteDurations. You may find it useful whenever you want to make musical notes for your Arduino speaker. This note table was originally written by Brett Hagman, on whose work the tone() command was based. So instead of writing the frequency in the tone( ) function, we’ll just have to write the name of the note. This file contains all the pitch values for typical notes. The code below uses an extra file, pitches.h. Pin: the pin on which to generate the toneįrequency: the frequency of the tone in hertz - unsigned intĭuration: the duration of the tone in milliseconds (optional) - unsigned long The Arduino pin can be connected to a piezo buzzer or other speakers to play the tones. Otherwise, the wave continues until a call to noTone ().

It g enerates a square wave of the specified frequency (and 50% duty cycle) on a pin. The program creates tones with a function, ‘tone( )’.
