Final Journal Entry (DIY Instruction Manual for Hell Rabbit) (Final Draft)

Project: Hell Rabbit

Team Members:

Irene Iarochevitch

Jorge Lara

John Moya

Frank Mason

Team Member Roles:

Irene Iarochevitch: As the more experienced in the wonderful field of Arduino (both in a hardware and programming capacity), she helmed most of the hardware that went into the construction of the Hell Rabbit toy. Specifically, she had done most of the soldering of the parts such as the servo motors, speakers, and LED Lights to the waveshield and making sure they came together and worked via the PIR Motion Sensor. She also helped to program a lot of the code that was used for the bunny, most of the the servo, sound and some of the LED portions. She is the brains behind the idea for the MOST scariest sounds that you most likely will ever hear coming out of a bunny.

Jorge Lara: He has the expertise as the LED Lights hardware technician and is largely responsible for the bunny having those red eyes that make you wish you was in 1st grade again. He is responsible for conjuring the idea that the bunny should have glowing red eyes whenever someone gets close to the bunny. His role from the beginning was to oversee the construction of the LED Lights (from a hardware standpoint) and how it could be implemented into the Hell Rabbit.

Jonh Moya. Another great LED Lights technician who helped to create the final design of the bunny’s eyes. In addition to the wonderful collaboration between Jorge and John, John also provided significant support with the computer programming portion of the LED Lights. He also assisted in soldering the LED Lights to jumper wires, which would eventually be soldered to the waveshield. Thusly, he helped to create to fear in adult men’s faces as they pass by the Hell Rabbit and give the toy its “Demon Eyes”.

Frank Mason: He is the computer programmer that helped to create the servo and sound portion of the project with assistance from Irene. His role was to ensure that when the hardware came together, it would function in accordance with the programming.

Background: We decided that we wanted to create a stuffed animal (filled with Arduino goodies) that could really scare the bejesus out of anyone passing by the bunny. We wanted to take everything we have learned from our Physical Computing class and apply that to what we think is a pretty cool project for many of us beginners. In this case, it would be a simple case of a Trojan horse encroaching upon enemy territory. It seems harmless at first, then BAM!!!!, RANDOM MUSIC, VIOLENT EAR MOTION, EYES OF THE DEVIL and warm greetings (not really).

Now, onwards to YOUR FUTURE SCARE.

The Hell Rabbit:

Note: Even though we used a fairly large bunny to house all of our equipment, you can use something of similar size and shape, just as long you know how to stuff all of the components inside of your toy.

Objective: To develop a toy that uses a PIR Motion Sensor to detect motion when someone approaches the bunny. It will trigger, thus activating random pieces of sound, LED Lights (in our case red), and will violently move its ears to alert that an individual is close to the toy.

Materials:

  • Stuffed Bunny

 

Procedure:

** To start, this tutorial will be created for hobbyists and beginners to Arduino who want a fun new project to embark on.

For more information about Arduino:

Arduino Homepage

Testing the Arduino Board

1. Now first, you will need to assemble all of the necessary pieces required for the early testing phases. We will be using the Arduino Uno Board. First, connect your USB B cable end to the Arduino Board and the USB A to the USB Port on the computer. Now, you press the reset on the Arduino Board to erase any leftover program on the Arduno. Then you upload a very common example known as the Blink example. If your Arduino board blinks then it is in good health.

Arduino Uno Board

USB A/B Cable

Soldering parts onto Waveshield (Speakers and Amplifier)

2. For this part, you will need to attach the Waveshield onto Arduino Board so that we may be able to move forward with the sound portion of the project. Next, you’ll want to insert the SD Card into the Waveshield (the waveshield stores the WAV sound files that will be needed for the output of sound). This part of our process was optional before, but we eventually had to use the Smokey Amplifier to increase the sound outputted from the Speakers.

Note: You are free to input whatever sounds you wish into the Waveshield, but all of them have to be pre-formatted to 16-bit, 22.050kHz.

For the remainder of this Journal Entry, it will be fairly technical in nature, but this is how we get to the good stuff and achieve what we want out of this project.

3. The first step is to solder the SD Card slot from your waveshield onto the Printed Circuit Board (PCB, which is the pins on the waveshield). Next you must add resistors (to prevent overload of electrical current from the waveshield to the speakers). Then, you must solder capacitors onto the waveshield. Finally, to attach a speaker onto the waveshield, you must solder jumper wires from the speaker to the waveshield.

What type and brand of speakers you use is up to you but we simply used one we thought could output the greatest amount of sound (or so we thought).

Tip: For an even greater output of sound, you could attach Smokey Amplifier to the Waveshield and increase your volume, but be aware if you end up going deaf by it, just a warning.

Speaker Attached to Adafruit Waveshield

SD Card for Waveshield

Jumper Wires

LED Lights

4. Now we will be tackling the LED portion of the project. First, you must solder your LEDs to your waveshield via jumper wires. To do this, you solder the legs of your LED’s to each jumper wire (it will be used like an extension wire in this case), which will be soldered to the waveshield. For our project, we used the super bright LEDs as the toy’s eyes to light up red.

Note: Once you soldered the LEDs onto the Waveshield, you can test the functionality of your LEDs by uploading the Blink example in the Arduino software. But remember to change the pins to the ones on your waveshield.

Servo Motor

5. At this time in our adventure, we are at the servo motor portion of our project. Servo motors have usually have three types of wires: signal, power, and ground. The power wire is typically red, the ground wire is typically black or brown and the signal wire is typically yellow or orange must all be soldered onto the waveshield. Note that servos draw considerable power, so if you need to drive more than two (which we did in for a time), you will probably need to power them from a separate supply source, which in this case would be a portable rechargeable battery. Be sure to connect the grounds of the waveshield and external power supply together.

Note: Once you are done soldering the wires of the servo motor onto your waveshield, you can test them using the Sweep example in the Arduino software.

RC Servo Motor

Finale (Hardware and Software come together)

6. We are finally at the juncture in this project where we take everything we have learned and give them a purpose. For this part of our project, we solder the PIR Motion Sensor’s power, ground and signal wires to the Waveshield.

Next, once you have ensured that ALL of your hardware (PIR, Waveshield, servo motors, LEDs, Speakers) is soldered and attached to your Arduino board, it is time to work on the software portion (the code) of the project. At this time, we will make all of the hardware activate through the PIR Motion Sensor. Once that is done, PRESTO!!! You have just created the craziest and fearsome toy in all the land, REJOICE!

Note: To test the functionality of the PIR Motion Sensor, you can use the PIRsense example from the Arduino Website.

PIR Motion Sensor

Our project with the PIR Sensor as its nose:

A video of our Hell Bunny in action:

Code:

Here is the totality of the code we have used to make the bunny come to life:

/*

 Motion activated “Hell Bunny”

Detects motion using a PIR sensor. When motion is detected plays a random wav file, with two LEDs

on while playing and (TENTATIVELY! two servo motors spinning in opposite directions)

 

The code is based on Adafruit “Pumpkin Project”: http://www.adafruit.com/blog/2008/10/15/freaky-scary-halloween-pumpkin-project/

 

*/

#include <FatReader.h>

#include <SdReader.h>

#include <avr/pgmspace.h>

#include <ServoTimer2.h>

#include “WaveUtil.h”

#include “WaveHC.h”

#include “Arduino.h”

 

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 filesystem on the card

FatReader f;      // This holds the information for the file we’re play

WaveHC wave;      // This is the only wave (audio) object, since we will only play one at a time

 // for PIR

 

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

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

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

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

 //int servoposition = 0;

 #define eyeleds 18;                // choose the pin for the LED

 #define DEBOUNCE 5  // button debouncer

 ServoTimer2 theservo;    // create servo object from the ServoTimer2 class

 ServoTimer2 theservo2;    // create servo object from the ServoTimer2 class

// this handy function will return the number of bytes currently free in RAM, great for debugging!

int freeRam(void)

{

 extern int  __bss_end;

 extern int  *__brkval;

 int free_memory;

 if((int)__brkval == 0) {

   free_memory = ((int)&free_memory) – ((int)&__bss_end);

 }

 else {

   free_memory = ((int)&free_memory) – ((int)__brkval);

 }

 return free_memory;

}

void sdErrorCheck(void)

{

 if (!card.errorCode()) return;

 putstring(“nrSD I/O error: “);

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

 putstring(“, “);

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

 while(1);

}

void setup() {

 byte i;

 // set up serial port

 Serial.begin(9600);

 putstring_nl(“WaveHC with “);

 putstring_nl(“buttons”);

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

 Serial.println(freeRam());      // if this is under 150 bytes it may spell trouble!

 // Set the output pins for the DAC control. This pins are defined in the library

 pinMode(2, OUTPUT);

 pinMode(3, OUTPUT);

 pinMode(4, OUTPUT);

 pinMode(5, OUTPUT);

 pinMode(6, INPUT);

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

 theservo.attach(7);

 theservo2.attach(9);

 //  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!)

   putstring_nl(“Card init. failed!”);  // Something went wrong, lets print out why

   sdErrorCheck();

   while(1);                            // then ‘halt’ – do nothing!

 }

 // 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!

 }

 // Lets tell the user about what we found

 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(){

 digitalWrite(8,HIGH);

 val = digitalRead(inputPin);  // read input value

 if (val == HIGH) {            // check if the input is HIGH

   if (pirState == LOW) {

     // Oh hey movement!

     Serial.println(“Motion detected!”);

      // Make scary eyes

           //Turn eyes on

    digitalWrite(18, HIGH);

      Serial.println(“playing”);

               // Play a sound:

    randNumber = 0;

    randNumber = random(4);

if (randNumber >= 1)

{

    randNumber = random(4);

    randNumber = randNumber + 1;

    Serial.println(randNumber);

        if (randNumber == 1)

        {

          playcomplete(“01.WAV”);

        }

       else if (randNumber == 2)

       {

           playcomplete(“02.WAV”);

       }

       else if (randNumber == 3)

       {

           playcomplete(“03.WAV”);

       }

       else if (randNumber == 4)

       {

           playcomplete(“04.WAV”);

       }

}

      // Go back to sleep

      Serial.println(“resetting for next run”);

      delay(5000);

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

     pirState = HIGH;

   }

 } else {

     digitalWrite(18, LOW);

     // we have just turned off

   if (pirState == HIGH){

     // we have just turned of

     Serial.println(“Motion ended!”);

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

     pirState = LOW;

   }

 }

}

// Plays a full file from beginning to end with no pause.

void playcomplete(char *name) {

   char i;

 uint8_t volume;

 int v2;

 // call our helper to find and play this name

 playfile(name);

 while (wave.isplaying) {

    theservo.write(544);

    theservo2.write(2400);

    delay(2000);

    theservo.write(2400);

    theservo2.write(544);

    delay(2000);

 }

 }

 // now its done playing

 

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();

}

This entry was posted in journals. Bookmark the permalink.

4 Responses to Final Journal Entry (DIY Instruction Manual for Hell Rabbit) (Final Draft)

  1. Yaro says:

    Wow Frank! This is awesome!

  2. michaelp85 says:

    Fantastic Post, When I heard the initial idea I did not think the complexity of the project could return what you guys came up with. BOY WAS I WRONG! Your work and hardships show that no matter the scale of a project making an inanimate come to life will always require a level of dedication your team has definitely exceeded. Good Job!

  3. Jorge Lara says:

    Great JOB Frank!!! you did a wonderful video, that’s some Emerging Muscle. The design seemed simple, but the integration was a challenge, Yaro is a hard working woman, congratulations. The success of this group was obviously do to “the absence of EGO”, we helped Yaro, as much as she needed or asked for our help, she’s a very independent woman. Everyone did their best to help the project. Frank until the very last day was relentlessly looking for any opportunity to collaborate, I gave many ideas, like the eyes, which was the whole reason why I joined the group, some where doable others very complex like the desire/idea to make it jump. Om Namah Shivaya

  4. I’ve been meaning to say for weeks now that I’ve really loved this project. Had my LED cape/jacket idea not gained traction I would have been all over this once. Congrats on a job well done!

Leave a Reply