Introduction: Talking Arduino Halloween Skeleton

Welcome to another of my instructables!

So Halloween is upon us again and I really wanted to use the Arduino I had.  I went to the halloween store and found a skull with a hinged skull and that was the spark that began this project.  I knew that it would probably be easy to have a servo move using the arduino and have it move the skull jaw up and down.




Step 1: Gather Your Materials

you'll need stuff.  Lots of stuff.  Well...not lots of stuff, but stuff from different places.  Here's a sort of breakdown of all the stuff I used and where I got it.

Arduino Duemilanove - $34.99
http://www.makershed.com/ProductDetails.asp?ProductCode=MKSP4

Ladyada Waveshield Kit - $21.95
http://www.makershed.com/ProductDetails.asp?ProductCode=MKAD11

2 Super Bright Red LED's - $1.79 for a 2 pack
http://www.radioshack.com/product/index.jsp?productId=3096133

PIR Sensor Module - $9.99
http://www.radioshack.com/product/index.jsp?productId=2906724

A small servo - around $13.00
Bought it at a RC hobby shop here in town

A skull - around $9

A black cloak halloween costume - around $10

various bones

Speakers

Wire

PVC and fittings - from lowes or home depot

hmmm.....seeing it all written out it seems like more money that I remember spending...haha.  Still though, to get animatronic halloween things premade you'd spend a bunch more that that.  That's what I'll keep telling myself to justify this.




Step 2: Build the Sound Shield

first thing you need to do is build your sound shield.  To save from repeating the wonderful step by step tutorial that lady ada made for her sound shield, I'll just put the link here to it.  One thing to note, I had the older version of this shield and didn't realize I was looking at the newer instructions until she was telling me to install pieces that I didn't have.  haha.  Make sure you are looking at the correct instructions before you start soldering.

V1.0 instructions
http://www.ladyada.net/make/waveshield/solder10.html

V1.1 instructions
http://www.ladyada.net/make/waveshield/solder.html

Step 3: Wire Up LED's

So here's how the LED's were wired up.  They are being fed 5v from the Analog 4 spot on the arduino.  What's great about this is that the arduino feeds out 5v, the LED's each require 2.5v, so the two of them are perfect for each other.

Step 4: Wire Up Motion Sensor and Servo

Here's how the motion sensor and servo are connected up.  these diagrams are done this way because I hooked all the wires in the skull up to a small project circuit board and then used CAT-5 Network Cable to run it down to the arduino.  The network cable allowed me to have more than enough wires to run everything I needed in one convenient package.

Step 5: All Together Now!

Here's the whole set up for the wiring in the skull.  Looks fairly simple in diagram form I think...

Step 6: One Other Thing...

You need to get a voltage reading of what the power of the audio is.  What this allows is whenever the volume on the sound gets loud enough, it opens the mouth of the skull.  Then when the voltage drops, the servo closes the jaw.  Fairly simple.  We'll attach a wire from a resistor and plug that wire into one of the inputs on the arduino so we can read it in the code. 

Step 7: Put Some Wav's on Your Card!

Grab yourself 4 wav files and format them as the lady ada tells you they need to be formatted.  If you want to use my code as is, you'll have to label them as follows on the card.  If you can figure out my code, you can just rename them to whatever you change the code to.  Anyways...use these names if you don't want to modify anything:


1.wav

2.wav

11.wav

13.wav

Step 8: Hook Up the Arduino

Hook up your arduino to the computer, copy and paste this code, and put it on your arduino.

If the code isn't visible below, I included a txt file of it so you can just download it that way.

-----------------------------------------------------------------------------------------------------------------------------------

#include
#include
#include "util.h"
#include "wave.h"

#define DEBOUNCE 100

#define swPin 14
#define eyeleds 18

AF_Wave card;
File f;
Wavefile wave;

int inputPin = 8;               // choose the input pin (for PIR sensor)
int servoPin = 16;              // choose the input pin (for Servo)
int pirState = LOW;             // we start, assuming no motion detected
int val = 0;                    // variable for reading the pin status for motion sensor
int minPulse     =  600;  // minimum servo position
int maxPulse     =  2200; // maximum servo position
int turnRate     =  1800;  // servo turn rate increment (larger value, faster rate)
int refreshTime  =  20;   // time (ms) between pulses (50Hz)
int mouthchange = 6;  //checks to see if mouth position needs to be changed
int randNumber;   //random number variable to allow the choosing of which wav will be played


/** The Arduino will calculate these values for you **/
int centerServo;         // center servo position
int pulseWidth;          // servo pulse width
long lastPulse   = 0;    // recorded time (ms) of the last pulse

void setup() {
  // set up serial port
  Serial.begin(9600);
 
  pinMode(inputPin, INPUT);     // declare sensor as input for PIR
  pinMode(eyeleds, OUTPUT);     // declare sensor as output for eyes


  // set up servo pin
  pinMode(servoPin, OUTPUT);  // Set servo pin 18 (analog 4) as an output pin
  centerServo = maxPulse - ((maxPulse - minPulse)/2);
  pulseWidth = centerServo;   // Give the servo a starting point (or it floats)


  // set up waveshield pins
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
 
  // open memory card
  if (!card.init_card()) {
    putstring_nl("Card init failed!"); return;
  }
  if (!card.open_partition()) {
    putstring_nl("No partition!"); return;
  }
  if (!card.open_filesys()) {
    putstring_nl("Couldn't open filesys"); return;
  }
  if (!card.open_rootdir()) {
    putstring_nl("Couldn't open dir"); return;
  }
}

void loop()
{
 
  val = digitalRead(inputPin);

  if (val == HIGH)
  {          
    if (pirState == LOW)
    {
      // we have just turned on
     Serial.println("Motion!");
     //Turn eyes on
     digitalWrite(eyeleds, HIGH);
     // Play a sound: 
     randNumber = 0;
     randNumber = random(3);
if (randNumber >= 1)
{
     randNumber = random(3);
     randNumber = randNumber + 1;
     Serial.println(randNumber);
         if (randNumber == 1)
         {
           playcomplete("11.WAV");
         }
       
        else if (randNumber == 2)
        {
            playcomplete("2.WAV");
        }
       
        else if (randNumber == 3)
        {
            playcomplete("13.WAV");
        }
        else if (randNumber == 4)
        {
            playcomplete("1.WAV");
        }
}
 


      pirState = HIGH;
 
    }
  }
 
  else
  {
    if (pirState == HIGH)
    {
      digitalWrite(eyeleds, LOW);
      // we have just turned off
      Serial.println("Motion ended!");
      // We only want to print on the output change, not state
      pirState = LOW;

     }
  }


}



void playcomplete(char *name)
{
  char i;
  uint8_t volume;
  int v2;


  playfile(name);
 
  while (wave.isplaying)
  {
      volume = 0;
      for (i=0; i<8; i++)
      {
        v2 = analogRead(1);
        delay(5);
      }

   if (v2 > 440)
        {
           pulseWidth = 1800;
           mouthchange = 1;
        }
           else
        {
           pulseWidth = 800;
           mouthchange = 1;
        }

  
  digitalWrite(servoPin, HIGH);   // start the pulse
  delayMicroseconds(pulseWidth);  // pulse width
  digitalWrite(servoPin, LOW);    // stop the pulse

  }
 
  card.close_file(f);
  digitalWrite(eyeleds, LOW);
  // we have just turned off 
}


void playfile(char *name)
{
  // stop any file already playing
  if (wave.isplaying)
  {
    wave.stop();
    card.close_file(f);
  }

  f = card.open_file(name);
  if (f && wave.create(f))
  {
    wave.play();
  }
}










Step 9: Test It!

I'm sure there's some other little things I've left out.  I'll continue to add to this as I remember.  This project took me over a month and grew larger and larger as I bought more things to add to it.  If it doesn't work, and you've followed all my instructions, dig deeper!  This isn't an end all, be all instructable!  Part of the fun in these projects is making it your own.  This project came about from me combining lots of other arduino projects I've seen around the web and that really is the best way to learn new things!  Have fun!  Experiment!

Comments

author
dwleo (author)2016-10-16

Hi,

Great Instructable! Would this work on the Uno?

author
SteveG20 (author)2016-07-30

Hey! Most of the links aren't working for the parts as of July 2016. Does anyone have an updated parts list, per chance? <3

author
AZAtheist made it! (author)2015-11-07

151107 Naomi the Witch

(http://azatheist.com/2015/11/07/fun-stuff-from-thi...

I made it! Sorta. This
year I decided to take my Halloween adventures into the world of Arduino. I saw
the “Talking Arduino Halloween Skeleton” on the Instructables.com website.
Halloween is the best time of year for a retired engineer and tinkerer like me.

The young men in the Intructables article were quite
energetic and their tutorial was wonderful. Instead of another skeleton I
wanted to build up a talking witch. It would be a bit of a challenge and I was
fortunate to have the “Talking Arduino Halloween Skeleton” to work from.

Naomi the talking witch
started out as a standard Halloween hanging prop from the Spirit Store and made in China. The original
prop had a voice box and glowing eyes but the voice was hard to understand. I
keep everything so perhaps the voice box will be used in a future project. I really wanted her
face and hands but I ended up using everything except for the voicebox.

The project involved
building an audio circuit board for the Arduino and making some special WAV
files for her voice. The board went together rather quickly and worked well. My
wife Nancy recorded the witch’s voice clips and did a great job. There were
challenges. The witch’s face was a solid chunk of plastic and I wanted her jaw
to move when she spoke. So I had to perform plastic surgery, for real! I used a
hot knife which is a #ll Exacto blade mounted on the end of a soldering iron.
This made the job easy. The hot blade works its way slowly through the plastic but doesn’t
take a lot of force. Here is a
video of the modified face with the servo to move the jaw.
Building the
frame came next along with a foundation. She came out very close to way I had imagined
and was the first active prop in the graveyard
this year
.

IMG_2371.JPG
author
Gh057 made it! (author)2015-10-20

WaveHC update for talking skeleton.

New Debugging features.

Shows voltage reading for servo tweaking.

I have not finished tweaking this yet but it does work. You may have to tweak a few things to make it work for you.

Have a happy Halloween!

#include <FatReader.h>

#include <avr/pgmspace.h>

#include <SdReader.h>

#include "WaveHC.h"

#include "WaveUtil.h"

#define DEBOUNCE 100

#define swPin 14

#define eyeleds 18

SdReader card; // This object holds the information for the card

FatVolume vol; // This holds the information for the partition on the card

FatReader root; // This holds the information for the volumes root directory

FatReader f;

WaveHC wave;

uint8_t dirLevel; // indent level for file/dir names (for prettyprinting)

dir_t dirBuf;

#define error(msg) error_P(PSTR(msg))

// Function definitions (we define them here, but the code is below)

int inputPin = 8; // choose the input pin (for PIR sensor)

int servoPin = 16; // choose the input pin (for Servo)

int pirState = LOW; // we start, assuming no motion detected

int val = 0; // variable for reading the pin status for motion sensor

int minPulse = 100; // minimum servo position

int maxPulse = 8200; // maximum servo position

int turnRate = 50000; // servo turn rate increment (larger value, faster rate)

int refreshTime = 3000; // time (ms) between pulses (50Hz)

int mouthchange = 6; //checks to see if mouth position needs to be changed

int randNumber; //random number variable to allow the choosing of which wav will be played

/** The Arduino will calculate these values for you **/

int centerServo; // center servo position

int pulseWidth; // servo pulse width

long lastPulse = 0; // recorded time (ms) of the last pulse

void setup() {

// set up serial port

Serial.begin(9600);

putstring("Free RAM: "); // This can help with debugging, running out of RAM is bad

Serial.println(FreeRam());

pinMode(inputPin, INPUT); // declare sensor as input for PIR

pinMode(eyeleds, OUTPUT); // declare sensor as output for eyes

// set up servo pin

pinMode(servoPin, OUTPUT); // Set servo pin 18 (analog 4) as an output pin

centerServo = maxPulse - ((maxPulse - minPulse)/2);

pulseWidth = centerServo; // Give the servo a starting point (or it floats)

// set up waveshield pins

pinMode(2, OUTPUT);

pinMode(3, OUTPUT);

pinMode(4, OUTPUT);

pinMode(5, OUTPUT);

// if (!card.init(true)) { //play with 4 MHz spi if 8MHz isn't working for you

if (!card.init()) { //play with 8 MHz spi (default faster!)

error("Card init. failed!"); // Something went wrong, lets print out why

}

// enable optimize read - some cards may timeout. Disable if you're having problems

//card.partialBlockRead(true);

// Now we will look for a FAT partition!

uint8_t part;

for (part = 0; part < 5; part++) { // we have up to 5 slots to look in

if (vol.init(card, part))

break; // we found one, lets bail

}

if (part == 5) { // if we ended up not finding one :(

putstring_nl("No valid FAT partition!");

sdErrorCheck(); // Something went wrong, lets print out why

while(1); // then 'halt' - do nothing!

}

putstring("Using partition ");

Serial.print(part, DEC);

putstring(", type is FAT");

Serial.println(vol.fatType(),DEC); // FAT16 or FAT32?

// Try to open the root directory

if (!root.openRoot(vol)) {

putstring_nl("Can't open root dir!"); // Something went wrong,

while(1); // then 'halt' - do nothing!

}

// Whew! We got past the tough parts.

putstring_nl("Ready!");

}

void loop()

{

val = digitalRead(inputPin);

if (val == HIGH)

{

if (pirState == LOW)

{

// we have just turned on

Serial.println("Motion!");

//Turn eyes on

digitalWrite(eyeleds, HIGH);

// Play a sound:

randNumber = 0;

randNumber = random(3);

if (randNumber >= 1)

{

randNumber = random(3);

randNumber = randNumber + 1;

Serial.println(randNumber);

if (randNumber == 1)

{

playcomplete("11.WAV");

}

else if (randNumber == 2)

{

playcomplete("2.WAV");

}

else if (randNumber == 3)

{

playcomplete("13.WAV");

}

else if (randNumber == 4)

{

playcomplete("1.WAV");

}

}

pirState = HIGH;

}

}

else

{

if (pirState == HIGH)

{

digitalWrite(eyeleds, LOW);

// we have just turned off

Serial.println("Motion ended!");

// We only want to print on the output change, not state

pirState = LOW;

}

}

}

void playcomplete(char *name)

{

char i;

uint8_t volume;

int v2;

playfile(name);

while (wave.isplaying)

{

volume = 0;

for (i=0; i<8; i++)

{

v2 = analogRead(1);

delay(5);

}

if (v2 <= 270)

{

pulseWidth = 1600;

mouthchange = 1;

Serial.println(v2);

}

else if (v2 <= 250)

{

pulseWidth = 700;

mouthchange = 1;

Serial.println(v2);

}

else

{

pulseWidth = 300;

mouthchange = 1;

Serial.println(v2);

}

digitalWrite(servoPin, HIGH); // start the pulse

delayMicroseconds(pulseWidth); // pulse width

digitalWrite(servoPin, LOW); // stop the pulse

}

digitalWrite(eyeleds, HIGH);

// we have just turned off

}

void playfile(char *name) {

// see if the wave object is currently doing something

if (wave.isplaying) {// already playing something, so stop it!

wave.stop(); // stop it

}

// look in the root directory and open the file

if (!f.open(root, name)) {

putstring("Couldn't open file "); Serial.print(name); return;

}

// OK read the file and turn it into a wave object

if (!wave.create(f)) {

putstring_nl("Not a valid WAV"); return;

}

// ok time to play! start playback

wave.play();

}

void error_P(const char *str) {

PgmPrint("Error: ");

SerialPrint_P(str);

sdErrorCheck();

while(1);

}

void sdErrorCheck(void) {

if (!card.errorCode()) return;

PgmPrint("\r\nSD I/O error: ");

Serial.print(card.errorCode(), HEX);

PgmPrint(", ");

Serial.println(card.errorData(), HEX);

while(1);

}

IMG_0988.MOV
author
Makemeasandwich (author)Gh0572015-10-31

Thanks for the update! I built this and have it mostly working, except I used a digital servo. I can't include the Servo library because of a conflict with WaveHC. It's pretty still works somehow, but the mouth opens way too much on the initial pulse. Any ideas how to adjust that?

author
crisx (author)2015-10-28

I need hints on communicqtion wiyh getti freq

1446058276985.jpg
author
Gh057 (author)2015-10-20

Oh and thank you so much! This tutorial is awesome! I really hope you make more videos and tutorials in the future!

author
Gh057 (author)2015-10-18

Ivogt I just got the WaveHC code working last night. I'll post the update after I get finish updating the servo code if I can. Probably a day or two.

author
lvogt (author)2015-10-12

Has any one modified this code to work with the latest version of WaveHC library?
Newbie needs help. Thanks.

author
Machine (author)2015-05-21

Very spooky! Love it.

author
Fission Chips (author)2014-10-24

Spooky! Nice work.

author
makerx3 (author)2014-10-09

I've met the creator of arduino and he signed my shirt

author
DocThomas (author)2013-08-22

getting to be that time again. planning Halloween stuff for this year.

how hard would it be to combine the mouth movement of this project with LED backpacks like here?
http://learn.adafruit.com/animating-multiple-led-backpacks

I'd love to have the mouth move and also have the creepy moving LED eyes in RED.

author
Jeff Haas (author)DocThomas2013-08-29

Since you'd be using Adafruit products for both the sound playback and the LED eyes, why not ask on their forum?

author
evil_ol_man (author)2012-11-19

Nice Instructable, and the project looks good. But....For less money than what you spent for the 2 Arduno boards and the aggrivation of putting them together you could have bought a Scary Terry Audio servo driver board From Cowalicious for $42.95 which is pretty much plug and play....Your Arduino kit comes to about $56.94. Just Curious as to why you did it that way.

author
gegy1 (author)2012-02-25

Hey!
Very nice instructable! I am searching a while, could please tell me somebody where to buy a skull like the one in the instructable. Best will be when i can buy it in germany or austria.
Thanks!

author
Raythe54 (author)gegy12012-07-13

Have you tried: http://www.skeleton-factory.com/ ?

author
Raythe54 (author)2012-07-13

Has anyone converted this for use with the WaveHC library, by any chance? I'm a total newbie to Arduino and stumbling through it at the moment.

author
tinker234 (author)2012-02-25

is there a way to make the servo quiet it seems a litlle loud

author
balak95 (author)2010-10-05

i get 9 error #include expects filename

sorry my key boards broke so some keys dont work, but yeah i compile this and get that error message is there anything i have to add, i need this by halloween.

author
Archos_User (author)balak952010-10-27

Make sure you include Ladyada's AF_Wave library from her site for the Wave Shield
Also missing in the code here, there are 2 Include statements that are blank right at the top of the code. "Instructables doesnt like the "<>" symbols posted in the code and it dropped the information after the #include statement. I typed out the names of the symbols here before and after the information that is required.

The first one should be #include (less than symbol) AF_Wave.h (greater than symbol)
The second one should be "#include (less than symbol)avr/pgmspace.h
(greater than symbol)
It took me a bit to figure out (i'm new to arduino and not a programmer) looking at other examples of code lead me to change those two include statements
I loaded the code last night (without a servo hooked up yet) and the wav portion works no problem.

Cheers

author
larsen e whipsnade (author)2009-11-15

Great Instructable. Anxious to re-task Mr. Skull!  When I try to verify the code on my Arduino, I get an error (looking for a particular filename). Any Ideas?

author

could be a library you are missing.  Take that error that you are getting and type it into google.  Whenever I had an error happen like that I was missing an arduino library I just had to download and throw into a folder.  Good luck!  Hope this helps!

author
depotdevoid (author)2009-11-03

I love it, this is totally awesome!  Someone else mentioned the waveshield recently, and after seeing what you've done with it, I'm totally considering buying one. 

I'm pretty new at all this arduino stuff, and I'd like to see the code you used.  Can you post it?

Thanks!

author
samseide (author)depotdevoid2009-11-07

see my reply to bill2009.  I don't know why it isn't showing up for some people, but it's there in step 8!  I'll attach it as a text file in that step too I guess!  I'll also message you a copy of it.

author
bill2009 (author)2009-11-05

for some rason I can't see the code.  Is it posted directly somewhere?

author
samseide (author)bill20092009-11-07

it's posted in step 8 and is visible on my laptop here in firefox.  I had the same problem you were having when I tried to pull it up at my work.   I don't know why that is.  I'll send you a message with the code in it.

author
mbrameld (author)2009-10-30

Might also be cool to use the voltage from the wav shield to set how wide the mouth opens. Open the mouth wider as the sound gets louder. I'd have to try it out, but in my head at least it seems like this would make the mouth movement a little more natural.

author
samseide (author)mbrameld2009-10-31

I totally get what you're saying.  It may look better.  Try it and let me know!  haha.

author
Lasrin (author)2009-10-30

A trim pot might have been better, taken off the other lead of the resistor.  This way you could adjust the sensitivity to the audio.

author
samseide (author)Lasrin2009-10-31

you can still adjust the sensitivity using the code by just telling it at what audio level the mouth should open.  So you could do it as a hardware or a software solution.

author
cool (author)2009-10-30

HAHA:  "Hey kids, come here, let me tickle your funny bone."

author
Tomboys (author)2009-10-30

This is really cool.  Wish I saw it sooner.

author
samseide (author)Tomboys2009-10-30

get an early jump on next year!  haha

author
samseide (author)2009-10-30

video has now been embedded!  Take a look!

author
fungus amungus (author)2009-10-28

Awesome, but needs video!

author
samseide (author)fungus amungus2009-10-29

a great friend of mine, and a great youtuber, is putting up a video documenting the build as well as showing it running.  Should be done sometime after 8pm CST 10-29-09.  Check back then as I'll put a link to it in the first step!

author
fungus amungus (author)samseide2009-10-29

You can even embed the video. Just click the "Video" button in the editor.

About This Instructable

57,378views

174favorites

License:

More by samseide:Mini Arcade Machines!Halloween Time MachineMorris the Hunchback Costume
Add instructable to: