Sunday, 29 December 2013

Audio playing toy with a PIC 16F1825

While we're waiting for our keypad membranes to arrive, and while a few other projects are waiting for parts (we really need some 5v zeners before trying our phone dialler in a live telephone point) last night's BuildBrighton Open Night was all about lasering and soldering.

Firstly, we made a PCB for our audio playing toy, small enough to fit inside the cute 50mm x 50mm cube that Steve managed to source from Farnell. It was based on our earlier clock project, but this time used a micro sd card holder and surface mounted 16F1825 PIC.



A hole was drilled in the top of the cube and a disc of acrylic inserted with magnets fixed into the top. These will both hold the toy shape in place and act as mechanical contacts for the resistor that is embedded inside each toy object, when placed on top. Small wires have already been soldered onto the underside of the magnets, and - of course - everything is held in place with plenty of hot glue!

[photo of inside]

The trickiest part of this was adjusting for the pinout of a micro SD card. Despite appearances, a micro SD card is not simply a smaller version of the full SD card. There is a subtle difference in where the pins go:


The thing to notice is that there is no second ground pin on pin 6 on the micro version of the SD card. When used in SPI mode, both pins 1 and 8 are not used. This meant that we couldn't just use the existing PCB layout from the earlier project, and had to build a fresh one from scratch (using ExpressPCB of course!)


The two pins labelled B are where the 3V battery is placed - ground at the top, power below. The two pins labelled R are where the wires connect to the magnets, and a resistor is placed across them. This completes a simple voltage divider onto pin RC4 which we can use to read the analogue voltage in, and work out which object has been placed on top of the box. The two pins labelled SP are where the speaker connects (it doesn't matter which way around) and the micro SD card holder is mounted such that pin one of the card is on the left hand side.

The code is a combination of the audio player code and analogue input code.
It is too long to list in one complete part here, but with a little imagination, it should be possible to combine the two to recreate this project!