It's easy to customize your Tilt Tones musical instrument by modifying the example program.
Turn Up the Beat
In the example program, beat CON 500 initializes the constant beat to 500. Later, beat is used as the FREQOUT command’s duration argument:
FREQOUT 1, beat, note
This makes the note last for 500 ms, giving you a little time to tilt the board to a new position to select a new note before the code repeats the DO…LOOP. If you want to slow down the beat, perhaps to practice the movements to play a tune, initialize beat to 750 or 1000. For peppier tunes — and a coordination challenge — try reducing beat to 250.
- Experiment with the beat!
It’s easy to modify the program to play different notes to make your own 4-note tunes. Simply replace the four elements in the LOOKUP, index[...], note list.
To make it easier to see which tilt motion will correspond to which frequency (and which LED will light up) insert this debugging code into your program, just below the LOOKUP statements:
DEBUG "index (binary) = ", BIN4 index, CR DEBUG "index (decimal) = ", DEC index, CR DEBUG "led = ", DEC led, CR DEBUG "note = ", DEC note, CR
Then, add this line just above LOOP:
Here's what the Debug Terminal would look like if you are tilting the board down to the right.
The familiar song Mary Had a Little Lamb uses only four notes: A, B, D, and G. It also has a simple, steady beat which works well for our Tilt Tones toy.
B A G A B B B A A A B D D Ma-ry had a lit-tle lamb, lit-tle lamb, lit-tle lamb, B A G A B B B B A A B A G Ma-ry had a lit-tle lamb, its fleece was white as snow.
- Referring to the keyboard diagram below, try modifying your program to use these four notes, then see if you can play the song.
The Piezo is Quieter on the HomeWork Board compared to the Board of Education because of the built-in resistor. Frequencies between 3000 and 5000 Hz tend to play louder than those above or below that range.