Make A "doorbell" using an Arduino Uno, a Wave shield from Adafruit, a small speaker, a plug, a Sharp distance sensor and a Shaun the Sheep.  Our Shaun is used in an open doorway to alert store staff when a customer has entered.

Step 1: Parts List

1. Wav Shield Party Pack (includes speaker and SD card) - $35
2. Arduino Uno - $30
3. Power plug - $7
4. Sharp Distance Sensor - $14.95
5. Shaun the Sheep found on eBay - make sure it is a large one .  Ours was the 16 inch one.
6. JST 3 pin cable - $0.99
6. Altoids tin or other small box
7. Needle & Thread
8. Electrical tape
9. Soldering Iron & Solder
10. Velcro tape or tabs from local hardware store

Step 2: Wave Shield

First assemble the Wave shield kit from Adafruit. 
It took us about two hours of soldering and wasn't too hard.  Just take your time and go slow.
You can find the Wave Shield complete directions here .

Step 3: Sounds

The next step is to find your sheep sounds and convert them to WAV files.  Note you cannot use MP3 files or any other kind of sound files.
Not having any live sheep handy to record, I found my sounds at Adopt A Farm .  The quickest way to convert files is to use iTunes.
Once again, Adafruit has complete directions on how to do this here.
Once you have 7 different sheep sounds label them BAA1.WAV, BAA2.WAV, etc..  Then put them onto your SD card and put the SD card back into the Wave shield.

Step 4: Test

At this point we put the Wave shield onto the Arduino and uploaded an example code from Adafruit.
If you don't have the Arduino software or IDE you can download it at Arduino.cc.  You will also need to download the WAV library.
Now plug speaker or some headphones into the headphone jack, just to test that it works.   If something doesn't work here, go back to the previous steps until you find what isn't working.

Step 5: Code

The next step is to add the code to your Arduino micro-controller.
If you don't have the Arduino software or IDE you can download it at Arduino.cc
Plug your Arduino into your computer and create a new project in the Arduino IDE. 
Paste the following code in and upload it to the Arduino.

// Sheep Doorbell // May 2011 by Todd Miller based on Adafruit example code // Plays one sound when sensor is triggered, in this case sheep baaing Uses 7
sounds and picks one at random // Parts include Arduino Uno, WAV Shield, small 8 ohm speaker and Sharp
GP2Y0A02 distance sensor // To be mounted inside a Shaun The Sheep from Wallace & Gromet
#include <AF_Wave.h> #include <avr/pgmspace.h> #include "util.h" #include "wave.h" AF_Wave card;
File f; Wavefile wave; // only one! uint8_t tracknum = 0; uint16_t samplerate;
#define sensorIn 0 int songCount = 7; int a[5]; int results;
int i=0; int maxDist = 0; int sensorRead = 0; int fr = 0; long previousMillis = 0; long interval = 3000;
void setup() { Serial.begin(9600); randomSeed(analogRead(1)); Serial.println("Wave test!"); pinMode(2, OUTPUT); pinMode(3, OUTPUT); pinMode(4, OUTPUT); pinMode(5, OUTPUT); pinMode(sensorIn, INPUT); if (!card.init_card()) {
// set up Serial library at 9600 bps
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;
} putstring_nl("Files found:"); ls();
for (i=0; i<5; i++) { // Get max distance for comparison later // maxDist += analogRead(5);
a[i]+=analogRead(sensorIn); } insertionSort(a,5); ls();
void loop() { readSensor(); uint8_t i, r; char c, name[15]; unsigned long currentMillis = millis();
if(sensorRead > (maxDist +20) && (currentMillis - previousMillis > interval)){ previousMillis = currentMillis; Serial.println(maxDist-25); int songNumber = random(songCount);
Serial.print("Playing track # "); Serial.print(songNumber); Serial.print(" "); Serial.println(name); switch(songNumber)
{ case 0: playcomplete("BAA1.WAV"); break; case 1: playcomplete("BAA2.WAV"); break; case 2: playcomplete("BAA3.WAV"); break; case 3: playcomplete("BAA4.WAV"); break;
case 4: playcomplete("BAA5.WAV");
break; case 5:
playcomplete("BAA6.WAV"); break;
case 6: playcomplete("BAA7.WAV"); break;
} sensorRead=0;
} card.reset_dir();
void playcomplete(char *name) { uint16_t potval; uint32_t newsamplerate; playfile(name);
samplerate = wave.dwSamplesPerSec; while (wave.isplaying) {
// you can do stuff here! delay(50);
} card.close_file(f);
void playfile(char *name) { f = card.open_file(name); if (!f) {
putstring_nl(" Couldn't open file"); return;
} if (!wave.create(f)) {
putstring_nl(" Not a valid WAV"); return;
} // ok time to play! wave.play();
} void readSensor(){
for (int i=0; i < 5; i++){ a[i]=analogRead(sensorIn);
insertionSort(a,5); Serial.print("max dis = "); Serial.println(maxDist); Serial.print("--- final sensor value = ");
Serial.print(sensorRead); Serial.println(" ---");
void insertionSort(int arr[], int length) { int i; int j; int tmp;
for (i = 1; i < length; i++) { j = i;
while (j > 0 && arr[j - 1] > arr[j]) { tmp = arr[j];
arr[j] = arr[j - 1]; arr[j - 1] = tmp;
} // array sorted, now lose low and high values for better average a[0]=0; a[4]=0; for (i = 0; i < 5; i++){ results= results+a[i]; } results/=3; // divide by 3 as places 1 and 5 = 0 if (fr == 0) { maxDist = results; fr = 1; } else sensorRead=results; results=0; }
void ls() { char name[13]; int ret; card.reset_dir(); putstring_nl("Files found:"); while (1) {
ret = card.get_next_name_in_dir(name); if (!ret) {
card.reset_dir(); return;
} Serial.println(name);

Step 6: Operation Cut Sheep

Now its time to cut open Shaun.  Make a 2 inch hole in the back and take out the body stuffing.  Leave the head stuffing in.
Now we cut a small hole in his nose for the distance sensor and pushed the three wires through.  attach the 3 pin jst cable to the distance sensor and push the wires through the hole you made.  Pull the wires out of the back.
We then had a little help sewing the sensor onto the nose through the 2 side holes on the sensor.

Step 7: Final Solder

Now solder the distance sensor wires onto the Wave shield. 
Using an Altoid tin lid I actually poked a large hole in it to put the wires through before soldering them.

A side note here - I also covered the inside of my Altoid tin with electrical tape to prevent any short circuits.

Connect the the black wire to GND the red wire to +5V and the third wire to analog pin 0. 
Once that is done solder two wires to the back of the speaker if needed.  Use lots of solder here and make a good connection.
Then solder the two wire into the 2 holes behind the headphone jack on the WAV shield. It doesn't matter which wire is +V and which one is GND.  Since my speaker had a big magnet I just put it onto the top of my Altoid tin.

Now attach the power plug and stuff everything inside.  I then used Velcro tabs to button the back shut.

Step 8: Done

Now place Shaun sitting up in a doorway with the sensor facing towards the opposite wall or door fram and then plug him in.  Wait a few seconds and walk through and he should be Baahing !

To see a video of Shaun in action, check out this YouTube video .
Hey, I'm doing this great project for my physical computing class, and I'm really stucked with the code... The library you were using doesn't exist anymore, Adafruit replaced it with WaveHC.h. I can't figure out how to modify the code for the new library. My wave shield keeps playing audio in a loop instead of randomly, and I can't incorporate proximity sensor into the code. If by any chance you know how to modify the code for the new library, you would save my life:) thank you for any help!
Well done!!!! Maybe have a look at my ibles as well<br>https://www.instructables.com/id/Remote-Controlled-Arduino-Car/<br>and<br>https://www.instructables.com/id/Star-Wars-X-Wing-2/<br>And vote for them if you like them in the microcontroller contest and the LED contest accordingly
This is a really great project... and what a cute sheep!
very neat and a interesting way to disguise the sensor!<br><br>personally i wouldve sewn the sensor more into the sheep, to make it less visible, but thats just me.<br><br>

About This Instructable




More by Paulys:Shaun The Noisy Sheep Arduino Fortune Teller Solar Light 
Add instructable to: