Play beats and change the sequence in real time. It’s basically all you need to become a hiphop artist. That, and rapper skills. But that’s another course.
Materials
- 1 Arduino board
- 1 Basic Education shield
- 4 680 ohm resistors
- 1 220 ohm resistor
- 1 470 ohm resistor
- 1 1.2K ohm resistor
- 8 ohm paper speaker
- 1 micro SD card
- 4 black loose wires
- 4 colored loose wires
- 1 black jumper wire
- 7 colored jumper wires
- 1 Sequencer kit
Instructions
Code
You can find the code in File -> Examples -> BasicEducationShield-> Magic -> Sequencer
How it works
Each heart shaped slot is connected to an analog pin and ground. Each heart has a resistor of different resistance and when it’s placed in a slot the resistor connects the slots wires. Since each heart has a unique resistance, it also has a unique reading. This means that we can distinguish which heart is connected to which slot.
In the program we use analogRead()
to read the analog value from a pin. We check which heart is connected in getSeq()
, that is which resistance is used. If it’s the 220 ohm resistor the function will return a ’1′ so that sequence
will equal ’1′. We use this value to decide which file to play. In this case it is “seq1.wav”. If no heart is connected to the slot the file “seq0.wav” is played, this is a silent file.
The procedure is repeated 4 times, 1 for each analog pin we are using. When it’s done, we do it again.
Troubleshooting
- Refer to the illustrations and double check all your connections. Make sure the shield and wires are firmly connected.
- Having problems playing the sound files? Check the reference for debugging the sound player.
- Make sure you are using the right resistors. Check the reference to see how to check it.
Experiment further
- Record your own 5 wav sounds and name them “seq0.wav”, “seq1.wav”, “seq2.wav”, “seq3.wav” and “seq4.wav”. They should all be equally long for the best result and “seq0.wav” should be silent. You can use Audacity (http://audacity.sourceforge.net/) to record sound that fits with Arduino. See reference Prepare Wav Sound for details.