Step 6: PicAxe Microcontroller and Code

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
2) Blues
3) Hungarian
4) Arabic
5) Hejaz
5) Chromatic

Tic 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.

So what chip did you insert in this tic tac tunes machine? I must'v missed it and can you buy it or do you have to make it?
This rules. I love the idea! I'm making an arduino version of this. Simply because I don't have the funds to dive into the PicAxe.
@ Coolkid4 Agree a Video will help <br>Basil <br><a href="http://www.everfocusonline.co.uk/CCTV-Security-Cameras" rel="nofollow">cctv cameras</a>
could you post a video tutorial on how to program the 08m2 chip
Here's an idea, change the instructable to use a 08M2 which has 2048 bytes of memory which means you can store all the programs on it and switch between them using a tactile switch connected to the unused PICAXE pin 3.
I made this around 3 years ago, well before the 08m2 came out, but yes, you could do a lot more with a re-write using an 08m2 (although I do quite like the challenge of getting maximum functionality out of a small device.)<br> Maybe one day, but I'm playing with polyphony on a 14m2 at the moment.
I have successfully made the Tic Tac Tunes. using the single gang slide pot made one half of the pot be the sounds and the other half the scales and its awesome. <br> <br>Here it is: http://youtu.be/22etKzCdVO4
Great! - Glad you like it.<br> I've got and even awesomer (?) thing in the pipeline, if only I ever get around to finishing it.
I could only get hold of a single gang 10k linear slide pot but it is the perfect tic tac box size and tests 0-9k with multimeter. I noticed in the program that there is only a readadc command on picaxe pin 4. Do I need both parts of a double gang pot? or will the single gang do fine.
My piezo sounder I have is almost half the size of yours and has no screw holes. It works with the PICAXE and it has a tiny hole in the bottom of it and a larger hole in the top. will it be safe to super glue it to the top of the chip? Or does the tiny hole at the bottom have to be uncovered. Either way, I could glue just the edge of it on the chip and it'd still fit i think.
Glue it to the chip - No problem.<br> Covering the small hole may make it slightly quieter, but try it by blocking it with your finger first to see if it makes a difference.
The amazingness of modern technology...
I think that this can also: http://www.rapidonline.com/Electronic-Components/PICAXE-08-Starter-kits-80318
no i'm from the netherlands its not so funny in the netherlands they dont sell picaxe and download cable for picaxe and socket
If there's no Picaxe supplier in the Netherlands then the UK Picaxe site, <a href="http://www.techsupplies.co.uk/epages/Store.sf/secef5ca3f4d2/?ObjectPath=/Shops/Store.TechSupplies/Categories/PICAXE" rel="nofollow">Techsupplies</a>, may be your best bet.&nbsp; It looks like postage for a smallish order to Europe is 3.6 Euro.&nbsp; They do all the parts you need.&nbsp;
can this piezo sounder to? http://www.ebay.nl/itm/2-x-Cased-Toko-Piezo-Audio-Sounder-With-Leads-30-x-4mm-/390377033134?pt=UK_BOI_Electrical_Components_Supplies_ET&amp;hash=item5ae448cdae#ht_1456wt_1139
what is the sort socket a: stereo PICAXE socket or a: Surface mount Stereo Picaxe socket
what will one tic tac tune cost if you have to buy everything (download cable)
<strong>&nbsp;</strong><br> Assuming you're in the US (I'm not), probably around $20 plus P&amp;P, half of which will be the programming cable.
i have a question<br><br>if i buy the picaxe 08m2 whats in the box (download cable, programming socket)<br><br>
<strong>&nbsp;</strong><br> That will just be the chip - The other parts you'll have to buy separately.&nbsp; The programming circuit is the 3.5mm socket and two associated resistors shown on the diagram as the chip is programmed in circuit.&nbsp; You will also need the AXE027 programming lead which you can get from the same place as the PicAxe chip.&nbsp; The software (Programming Editor) is a free download from the <a href="http://www.picaxe.com/Software" rel="nofollow">Picaxe site</a>.
How do I program it??
Could a 330 ohm 1/2W 5% Carbon Film resistor be used in place of the 330r Resistor or is that the equivalent??<br>
I love it!!!
Whats the difference between each one?<br><br>Which one should I use?
You dont know where the cheapest place is to buy dual gang potentiometers? I would love my students to have ago at this circuit but at $12 a pot they are to expensive. Is there any other thing that would replace the dual gang pot? <br> <br>Madbutler
I found the picaxi 08M and pic12f683 out in market.are they the same thing?
no, PICAXE is pre programmed so that you can 'program' in BASIC unlike PIC which is different
Nice...but I tried my hand at PICAXE chips...<br><br>I like pics more though (No offense, though.)
Great instructable AndyGadget,<br><br>I was just about to make an order on Tech Supplies for the PicAxe chip, but then I realised that the link is broken for me. Is there any other website that sells them and will ship to the UK?<br><br>thanks,<br>Z<br><br>(Now, off to maplin!)
<strong>&nbsp;</strong><br> Are you using an old bookmark link?&nbsp; The site moved a few months ago.<br> Currect address is <a href="http://www.techsupplies.co.uk/">HERE</a>.<br> <br> They're shipping the 08M2 now which is a more powerful replacement for the 08M, but It should work in this circuit&nbsp;- Please let me know if it doesn't.<br> (I know there's a problem using the 08M2 with my Piecax project, but I'm working on resolving that.)
Thanks, this link works fine for me. <br><br>Does the 08M2 cost any more than the 08M? If the price is the same or similar I shall be giving it a try.<br><br>Z<br><br>Oh, and just to confirm, I only need the Chip and the cable right, not the CD disk or any of the things, correct? I don't want to make an order to find out that I am unable to program it. <br><br>Thanks!<br>
<strong>&nbsp;</strong><br> I think the 08M2 is cheaper than the old 08M.&nbsp; The reason is that it's a custom masked item from Microchip (i.e. a component in itself) and not a standard PIC programmed by RevEd like the 08M was.<br> <br> You only need the cable and chip - yes.&nbsp; The software you download from <a href="http://www.rev-ed.co.uk/picaxe/">HERE</a>. You'll need the Programming Editor and the AXE027 drivers.&nbsp; While you're ordering, get yourself another 08M2 and a <a href="https://www.techsupplies.co.uk/epages/Store.sf/sec267655f825/?ObjectPath=/Shops/Store.TechSupplies/Products/AXE021">proto-board</a> too for playing about with.&nbsp; Also a <a href="https://www.techsupplies.co.uk/epages/Store.sf/sec267655f825/?ObjectPath=/Shops/Store.TechSupplies/Products/BAT020">battery box </a>to power it.&nbsp; It's amazing how many things you can do with just that setup and using different sensors and output devices.&nbsp;<br> <br>
Thanks for your help, AndyGadget! I will get back to you in the future as to how it works!
Is there anywhere I can buy a finished &quot;Tic-Tac Tunes&quot;?
<strong>&nbsp;</strong><br> Nope, you'll have to make it yourself.<br> (If you're after something ready-built, there's always the <a href="http://www.amazon.co.uk/Stylophone-Original-Pocket-Electronic-Organ/dp/B000SKHSRU">Stylophone</a>.)<br>
How would you classify those audio files above? How would you describe their genre?
<strong>&nbsp;</strong><br> I've got another project in development which generates an endless succession of this sort of tune (algorithmic music generation) and I may set it up as a <a href="http://www.shoutcast.com/">ShoutCast</a> station.&nbsp; I think the genre which best defines it is 'experimental'.<br>
Thank you very much. :)
cool soldering iron
<br> Thanks, and I'd bet money that it's a lot older than you are.&nbsp; I've been using it since the early 1980's (but had to change the bit a few times #;&not;)<br>
With the peizo sounder, what colour wire attaches to the Picaxe?
<strong>&nbsp;</strong><br> It doesn't matter - Connect the piezo either way around.&nbsp;<br> <br> That only comes into play when you're using two or more speakers :-&nbsp; If you connect them different ways around then one is 'pushing' the air in one direction while the other is pushing in the other, so the pressure waves (sound) from each would tend to cancel out to some degree.<br> This is very noticeable with stereo loudspeakers if you connect them to the amplifier with one reversed. (It's called 'phase reversal'.)<br>
soory to be a bother, but where abouts does the programming socket connect to, it's just that in the picture it looks like nowhere.
<br>Look at the 3rd picture in step 2 showing the back of the board. The socket is in the top right . The top 2 are linked and the bottom 2 are linked. The tracks connect to the rest of the circuit. Relate the top side photo to the bottom side and the circuit diagram to see where.
could you please tell me where abouts the wires for the keyboard go, as i can't quite tell from the pictures.
<br>If you hover over the yellow boxes on the 4th picture on step 2 it shows the keyboard connections to the top track (+V), in the middle (to the IC pin 3) and bottom track (0V).
it's ok now, i just hadn't read the previous slide properly!
i ade y tic-tak box into an i pod i s took apart an old ipod and sed the parts i took off the screen thogh
<br><br>Could you make one into a keyboard?<br><br>(You appear to be having a little trouble with yours #;&not;)

About This Instructable


353 favorites


More by AndyGadget: Simple Effective Mouse Catcher Auto-lock mod for smartphone case The Orange Screamer
Add instructable to: