This sort of works as an LP player. The difference is that instead of using a needle on a plastic disc, we use three IR sensors in a row to read a pattern from a paper disc. If you are both musically and digitally inclined, you will have lots of fun creating melodies with this.
- 1 Arduino Uno board
- 1 Basic Education shield
- 1 Piezo
- 1 IRArray
- 2 black jumper wires
- 5 colored jumper wires
- Binary LP kit
- Binary LP paper disc
- Attach the shield onto the top of the Arduino board.
- Connect a piezo speaker to the breadboard and connect one leg to digital pin 8 and the other to GND.
- Connect 5 loose jumper wires to the board, 1 black to GND, 1 red to 5V and 3 in different colors to A1, A2 and A3. These will later be connected to the IRArray so remember what color is connected to what.
- Assemble the box and the lid. (But don’t put on the lid just yet.)
- Place the Arduino board in the box, connect it to the computer, and upload example BinaryLP.
Put the loose wires through the hole on the lid of the LP player.
Place the lid on the box, and the gears on the lid.
Place the IRArray in the holder.
- Connect the loose wires to the IRArray. 5V to 5V, GND to GND, A1 to IR1, A2 to IR2, A3 to IR3.
- Use the processing sketch in the example folder to make your own disc. Print out the PDF it creates – make sure to print it Actual Size (not Fit to Page).
- Tape the disc to the turntable making sure to correctly align the markings so that it is centered.
You can find the code in File -> Examples -> BasicEducationShield-> Magic -> BinaryLP
How it works
The three IR sensors in the IRArray can detect black or white from the paper disc. This means that we can detect 8 different combinations of black and white. Do you remember how to count in binary? That will come in handy right now. In the program we use the command
readBinary() to read from the disc and receive a value from 1 to 7. If the pattern is white, white, black, we receive a ’1′. If the pattern is white, black, white, we receive a ’2′ etc. We then use the read value to play a note. You decide what note to play for each number in the function
playNote(). E.g. if we receive a ’1′ we play
NOTE_C4 and if we receive ’2′ we play
NOTE_D4. In this example we are using the tones from the scale C major. Check the tab “pitches.h” to see what other tones you can use. If we read a ’0′ we don’t play a specific note, instead we let the white space decide how long the last note is played The longer the white space, the longer the note. If the last note we played is the same as the current, we let the piezo be quite for 20 milliseconds so that we can distinguish 2 different notes.
- Refer to the illustration and double check your connections. Make sure the shield and wires are firmly connected.
- Debug the IRArray, see the IRArray reference.
- Compose a few different melodies.
- Come up with new way to use the binary readings.