Adding Sound and Movement

Electronics Block Diagram

The wiring diagram works like this:

  • P22, 23, 24, 25 are pre-wired to the SD card socket

  • P12 to the Head Servo

  • P13 to the Arm Servo

  • P17 to the PIR Sensor

  • P0 and P1 to the eye NeoPixel rings

  • P17 to the Speaker

Block diagram for the electronics of the Spooky Doll.

A Parallax 7.5V 1.5A Power Supply (#750-00009) is plugged into the power jack. The P12 and P12 servo header jumpers are at Vin (7.5V). The P17 servo header jumper is at Vdd (5V). The two NeoPixel were soldered to three wires each for data, power and ground.

 

Creating WAV Audio Files for the SD Card

Parallax has produced tutorials on this subject. Using Audacity, you can record and modify your own sound effects, or import your own music or files. The instructions for creating the correct format are available in our Sound Library reference section.

  • To load the sounds onto the microSD card, you can use SimpleIDE or another IDE with file-uploading capability, or an external SD card reader.

 

BlocklyProp Code

The Spooky Doll Animation has two key features which run in additional Propeller Multicore processors: the NeoPixels in the eyes and the WAV file playback. This is necessary because the eyes fade even red to blue (and back) even if the animation has not been activated by the PIR Sensor. The concept is that curious onlookers will be drawn towards the doll’s eyes before it activates. The WAV files also play concurrently with the eye fading and servo control.

You can open and clone the entire BlocklyProp code here: http://blockly.parallax.com/blockly/editor/blocklyc.jsp?project=50835#. You will need to log in to use or clone the program.

The pseudocode for this project works like this:

  1. Start LED eye fading from red to blue, and back

  2. If motion is detected (human, pets, etc), the PIR Sensor is triggered and the following sequence begins:

    1. “butcher.wav” sound file is activated and plays “Come and get your meat!. . .”

    2. Head servo centers

    3. Arm servo goes up and down

    4. “Yuck.wav” sound file is activated and plays a maniacal laugh “muhahahaha!”

  3. Process repeats if PIR Sensor is triggered again

 

The entire code is shown below, with servo control blocks in the collapsed state.

BlocklyProp code for Spooky Doll.