Don't Touch the Package

by MikeTheMaker in Circuits > Arduino

21772 Views, 88 Favorites, 0 Comments

Don't Touch the Package

scream32.jpg


If you touch the package, it will scream and run away--changing its course when it strikes an obstacle.

When you lift the gift tag, light strikes a photocell and operation commences.  Motors and a sound module are controlled by an Arduino (and Arduino Motor Shield).

Major components required are:

Motorized toy--Kid Galazy Morphibians Rover Remote Control Car; Amazon.com
Arduino Uno
Arduino Motor Shield
Recording Module--Radio Shack 276-1323
Photocell--Jameco 120299
Relay--Jameco 139977
DPDT switch
1K resistor
10K resistor
2n2222a transistor
1n4004 diode
(7) AA batteries
9 V battery
Battery holders
tape, screws, mounting hardware, wire, wire wrap wire, heat shrink tubing, solder
cardboard, wrapping paper
support structure (I printed mine with a 3d printer--it could be made from plywood)  http://www.thingiverse.com/thing:38370
 

scream34.jpg
In concept, this is fairly simple.  Lift the tag and light strikes a photocell--triggering the action.  The sound module plays a prerecorded "Eeek" and the package backs up, turns and takes off.  The Arduino/Motor Shield monitors current going to the motors.  When the package strikes an object, one or both motors struggle to operate and draw an increased amount of current.  The increase in current lets the Arduino know it is time to play the "Eeek," then back up, turn and take off.  This continues until the master toggle switch is turned off.

Add "+" from the recording module to the top of the relay/1n4004 diode.

scream01.jpg
scream1.jpg
Remove the passenger compartment of the car.

scream2.jpg
scream3.jpg
Separate the bottom of the car from the top by removing the screws in the base.

scream4.jpg
Cut the wires to the receiver module and save the module for a future project.

scream5.jpg
scream7.jpg
Drill holes in the battery compartment and bring the motor wires through those holes.

scream8.jpg
Solder extension wires to the motor wires.  I use heat shrinkable tubing to secure the connection.

scream02.jpg
scream03.jpg
Take the printed "screaming base" (see Thingiverse -- or make one from plywood) and route the wires through the center.

scream04.jpg
Secure the base to the wheel platform with screws.

scream05.jpg
On the back side of the Arduino Motor shield is an area labeled "Vin Connect."  Cut the trace between the two "squares" with a knife.  This keeps the motor power and computer power separated.

Tape or screw the Arduio/Motor Shield to the base.  Fasten the motor wires to the Arduino Motor Shield.

scream06.jpg
Add batteries and battery holders--I fastened them with Velcro tape.

scream07.jpg
Record the "Eeek" on the sound module.  Remove the "play" button and solder two small wires (I use wire wrap wire) on the traces that are under the "play" button.  Using a breadboard, set up the relay, recording module and transistor.

scream08.jpg
scream09.jpg
Using Velcro tape, add the sound module and associated circuitry to the car.

scream10.jpg
scream11.jpg
Fasten the "package support" (side piece) to the base.

scream12.jpg
Add the other side piece.

scream14.jpg
scream13.jpg
Glue the "scream support" to the side pieces.

scream15.jpg
Add the other support piece.

scream16.jpg
Take a "U" shaped piece of cardboard--the exact width of the structure--and bend it into place.  The front and back should clear the ground by about 1/2 inch each.

scream17.jpg
Punch a hole--this is the future location for the photocell.

scream19.jpg
scream18.jpg
Cut and glue side pieces of cardboard to the box.  This will take quite a bit of shock, so it needs to be secure.

scream20.jpg
Tape the sides for further strength.

scream26.jpg
Wrap the package.  The gift tag must be the type that opens up (to expose the photocell).

scream22.jpg
scream25.jpg
Solder the photocell, resistor, lead assembly together.

scream21.jpg
Install the dpdt (double pole, double throw) switch in the path of the two power supplies.  I use two power supplies because the dips and spikes on the motor circuitry tends to cause problems if used for the Arduino.

scream30.jpg
scream28.jpg
Punch a hole and install the switch.  This is the "on-off" switch for the device.

scream29.jpg
Run the wires from the gift tag through the hole to the inside of the box. 

scream24.jpg
Insert the wires from the photocell into the Arduino assembly.

scream30.jpg
scream28.jpg
Install the software below. 

analogRead(2) values determine the trigger point for the photocell.
analogRead(0) and analogRead(1) values determine the current which will cause the Arduino to think the package has hit an obstacle.  If you run on carpet, the values may need to be higher.  If you run the motors faster, the value may need to be higher.

Note that the "startup current" on motors is greater than the "run" current--that's why there is a delay on forward before checking the current values.



int valm=0;
int valm1=0;
int trigger=0;
int triggerlock=0;
const int pwmA=3;
const int pwmB=11;
const int brakeA=9;
const int brakeB=8;
const int dirA=12;
const int dirB=13;
const int relay=7;

void setup() {


pinMode(relay, OUTPUT);


digitalWrite(relay, HIGH);

delay(500);//leave relay on .5 second--makes "eek" sound
digitalWrite(relay, LOW);
}

void loop() {
 
  trigger=analogRead(2);
  if(trigger<900 or triggerlock>0) {//light shining on sensor now or previously
   
    triggerlock=10;//don't check light again
  
   
    pinMode(dirA, OUTPUT);
pinMode(brakeA, OUTPUT);

pinMode(dirB, OUTPUT);
pinMode(brakeB, OUTPUT);

digitalWrite(dirA, HIGH);//forward A
digitalWrite(brakeA, LOW);//release brake A
analogWrite(pwmA, 150);//set speed A

digitalWrite(dirB, HIGH);//forward B motor
digitalWrite(brakeB, LOW);
analogWrite(pwmB, 150);//set speed B



valm=analogRead(0);
valm1=analogRead(1);
if(valm>520 or valm1>520) {
 
digitalWrite(relay, HIGH);//turn on "eek" sound
delay(100);
digitalWrite(relay, LOW);
digitalWrite(brakeA, HIGH);//stop motor A
digitalWrite(brakeB, HIGH);//stop Motor B

digitalWrite(dirA, LOW);//reverse A
digitalWrite(brakeA, LOW);//release brake A
analogWrite(pwmA, 150);//set speed A

digitalWrite(dirB, LOW);//reverse B
digitalWrite(brakeB, LOW);
analogWrite(pwmB, 150);//set speed B

delay(300);

digitalWrite(brakeA, HIGH);//stop one wheel

delay(400);
digitalWrite(brakeB, HIGH);//stop other wheel



//start both wheels forward
digitalWrite(dirA, HIGH);//forward A
digitalWrite(brakeA, LOW);//release brake A
analogWrite(pwmA, 150);//set speed A

digitalWrite(dirB, HIGH);//forward B
digitalWrite(brakeB, LOW);
analogWrite(pwmB, 150);//set speed B

delay(700);//get past startup current

}}}

scream31.jpg
scream32.jpg
Make sure that all wires are connected and all batteries installed--and the switch is off.  Carefully pull the cardboard cover over the shell.

Set the package in place and turn the switch "on."  You should hear one "Eeek."  The package should remain still.  When someone lifts the gift tag, the package will take off; scream every time it hits an object, and continue running until caught and switched off.