This fun and simple project called Scary Halloween is intended, you may have guessed it, for Halloween, but not limited to it.
The concept is simple: when somebody walks past the PCB, a PIR sensor will trigger, a scary sound will play (i.e. a witch's laugh) and a few LEDs wil light up. This PCB will be designed to be put in a pumpkin. Of course you can use this gadget for other events too, just change the packaging and the sound to be played.
To play the sound I decided to use a WTV020SD-16p module, which is a micro sd card reader that plays a sound from the micro sd card up to 512 sounds and supports up to 1 GB micro sd cards, though it also works with 2 GB. for the PIR sensor, I'll be using a HC-SR501 module. As for the MCU which controls the micro SD card reader, the ATTINY13 will be used, because I don't need a lot of I/Os.
I started designing the schematic to get a basic idea of how I should build a prototype on a breadboard to test the sd card module.
After I made the schematic, I build a prototype on a breadboard to test the micro SD card reader with an arduino uno. Unfortunately the WTV020SD-16p can only accept 3V3 so I needed to put 470 ohms resistors on the inputs. The sounds in the datasheet are referred to as voice, so I will be using that too.
The WTV020SD-16p has 16 pins, hence the 16p part, 4 of which are not connected (pins 3, 6, 11 and 14) and 2 are used for the power supply (pin 8 is the GND and pin 16 is the VCC). That leaves 10 ports to use.
Pin 1 is the reset pin,
pin 2 is for an audio amplifier,
pin 4 and 5 are used for a direct connection to a speaker,
pin 7 is the clock pin for communication with a MCU,
pin 9 is a manual play/stop pin,
pin 10 is the data pin for communication with a MCU,
pin 12 is the previous voice for manual selection,
pin 13 is the next voice for manual selection
and pin 15 is the busy pin which will trigger when a voice is playing.
In my prototype on the breadboard I used pins 1, 7 and 9 to choose the voices via software, because with the software I can choose the voices in any order I want. A LED with a resistor is connected from the Vcc to pin 15 to indicate when the module is busy. When the LED is on, the module isn't busy, when it's off, the module is busy. The busy LED won't be included in the final design.
My experience with this module so far was pretty poor. First I needed to change the format of my files, from .mp3 to .ad4, an extension of which I never heard of before. And those files have to be named in numeric order beginning with 0000.ad4. I started with 1 file to test with which was just a random mp3 file which i converted to ad4.
After the conversion I wanted to test it, but it wouldn't want to play the voices even when I manually tried to play them. after some searching on the internet, I found out that the micro SD card reader doesn't like certain micro sd cards. I initially tested it with a no name 2GB micro sd card, which at first didn't work. After I received a Sandisk 2GB sd card it suddenly worked. After too much experimenting with the no name micro sd card, it suddenly worked, but i didn't know why because I changed nothing. I tried putting more voices on the card to test if it works with more than 1 voice, but it seemed that I played a little too much with the no name card as the computer couldn't recognize it anymore.
The Sandisk card seemed to work without too much problems even when I tried multiple voices.
Now that I could play the sounds manually, I decided to try to write a simple program. After I followed the datasheet as precisely as I could, nothing happened, even when I confirmed the data and clock transfer with an oscilloscope! (link to the datasheet: https://docs.google.com/file/d/0B4p82-pNB6o7ck03ZndpYUZGOFU/edit?pli=1)
The very next day I found out that I forgot to add the 470 ohms resistors on the data, clock and reset pins. After I fixed that, it worked perfectly fine. whoops!
The schematic needed to be updated to include the PIR sensor, the LEDs and the sd card module. Unfortunately the PIR sensor module only works on a 5V power supply and the sd card module only works on 3V3, so 2 diodes are needed behind a 7805 to make it ~3V3. I put a 7805 on the design, so it can be powered with a 9V battery, or a 9V power supply.
Now I only need to write the firmware for the ATTINY13 and I need to find some scary sounds to finish my Haloween project.