Don't Touch the Package
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.
Add "+" from the recording module to the top of the relay/1n4004 diode.
Remove the passenger compartment of the car.
Separate the bottom of the car from the top by removing the screws in the base.
Cut the wires to the receiver module and save the module for a future project.
Drill holes in the battery compartment and bring the motor wires through those holes.
Solder extension wires to the motor wires. I use heat shrinkable tubing to secure the connection.
Take the printed "screaming base" (see Thingiverse -- or make one from plywood) and route the wires through the center.
Secure the base to the wheel platform with screws.
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.
Tape or screw the Arduio/Motor Shield to the base. Fasten the motor wires to the Arduino Motor Shield.
Add batteries and battery holders--I fastened them with Velcro tape.
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.
Using Velcro tape, add the sound module and associated circuitry to the car.
Fasten the "package support" (side piece) to the base.
Add the other side piece.
Glue the "scream support" to the side pieces.
Add the other support piece.
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.
Punch a hole--this is the future location for the photocell.
Cut and glue side pieces of cardboard to the box. This will take quite a bit of shock, so it needs to be secure.
Tape the sides for further strength.
Wrap the package. The gift tag must be the type that opens up (to expose the photocell).
Solder the photocell, resistor, lead assembly together.
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.
Punch a hole and install the switch. This is the "on-off" switch for the device.
Run the wires from the gift tag through the hole to the inside of the box.
Insert the wires from the photocell into the Arduino assembly.
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
}}}
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
}}}
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.
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.