Code posted below in Word and Programming Editor formats. If you have trouble opening the code file, use 'save link as' and rename the .tmp file to .bas. I'll be commenting the code after the current re-write, but here's a quick summary :-Tic Tac Tunes
starts up after programming in 'sleep' mode. When asleep, the unit wakes briefly every 4 seconds and checks one of the ADCs (analogue to digital converters). If this reads 255 it wakes up. The ADC is held at 0 with no contact with a pulldown resistor.
Tic Tac Tunes now uses the ADC to read the track value which gives a reading from 0 to 255. The solder blob is at the positive rail voltage, so reads 255.
When awake, additional 255 pulses increase the tempo of the played notes (flashing the LED for each contact), and once the count gets to 8, it reverts to 1 and also switches to the other scale of notes (long LED flash). The PicAxe can only produce notes with a fixed duration, hence the need for the tempo control.
The tracks are in series, so the far end reads at around 127. This value is split in the software to upper and lower keyboard, and then into 18 notes, with 8 divisions for the percussion. An ADC value of zero (probe not touching) gives silence.
The percussion sounds are generated with a chunk of PicAxe SOUND commands, and the notes using TUNE. A watchdog timing loop is reset every time a note is played and if this doesn't happen at least every 20 seconds or so the unit goes into sleep mode until next awoken.Tic Tac Scales
adds more scales to the box, but drops the percussion. Turn on in the same way as Tic Tac Tunes, and select tempo and scale with the control blob. The LED will flash with tempo changes, and also beep as the scale changes to show the scale loaded. They are :-
1) Minor pentatonic
5) ChromaticTic Tac Beat Box
is a free-running beat generator. Start it up by touching the probe anywhere on the top track. It will then invent random beat sequences with 2 to 5 beats, at a range of tempos. It also mixes two sets (at the same count and tempo) to give a bit of variety. Every now and then, it starts a new set. At the start of each set the LED will flash to show the beat count, and gives a brief flash at the start of each bar. Touch the top track again to put it to sleep.The PicAxe
was initially developed for the educational market in UK schools but is being widely used by hobbyists. The PicAxe is based on various PICs but with bootstrap code to interpret the downloaded programs and handle the programming side. They come in all flavours from this suprisingly powerful 8 pin package up to full blown 40 pin.
Look at the manuals and datasheets on the PicAxe site
to see the full capabilities. Programming of the chip is via a serial link and done in-circuit. It takes about 20 seconds and you don't even have to unplug the lead to run the program.
I've been in electronics since the early eighties and I've never found a programming environment where the coding / simulation / proving cycle is so simple. Documentation and support from the forum
is excellent and there are many robotics enthusiasts using the chips. Control for servos, steppers, ADCs etc are built in to the BASIC-like programming language as well as a host of other goodies. You can also simulate the circuit before you build, and do real-time debugging on a running controller. Look out for more PicAxe based projects from me.