Michael Seppanen shows us how to use a Basic Stamp microcontroller combined with a Park Zone Stoplight, and a hacked Epson printer to make a pumpkin pop up automatically when a trick or treater comes to the door. A nice way to use your microcontroller talents to scare some kids!
This article was submitted by Michael Seppanen as part of the “Hobby parts for articles” program. Michael receives a Modern Device Company Bare Bone Arduino Kit for this great article.
I wanted a way to make a pumpkin pop up out of the column every time a trick or treater came to the door. I ended up using a Park Zone parking stoplight to sense the trick or treaters. I used this because they are cheaper than buying an ultrasonic sensor, easy to set up, and this was the sturdiest sensor that I had at the time that could sense people.
My setup included the parking stoplight with a photo resistor attached to the red LED. The BASIC stamp waits for the photo resistor to return the value of the light turning on and then starts the stepper motor. The stepper motor lifts the printer head which holds a metal shaft that is attached to the pumpkin.
When the printer head reaches the end stop switch, the stepper motor holds its position and then reverses direction to send the pumpkin back down again. All of the parts to lift the pumpkin came from an old Epson dot matrix printer. I used the printer head assembly and the stepper motor that moves the printer head. The printer also had the end stop switch built in.
In very simple terms, a photo resistor changes the amount of resistance between the two leads as the light changes. This change is detectable by a microcontroller with a resistor-capacitor time circuit. The resistor in this case is the photo resistor and the capacitor is .01uF. The capacitor is filled with electricity by the ‘HIGH’ command. As the resistance changes in the photo resistor, the amount of time that the capacitor takes to discharge is measured by the command ‘RCTIME’. This process has to be repeated over and over to get multiple readings over time. In this case, the light value is read until the red LED turns on.
A stepper motor differs from a standard motor since the stepper motor has five or six wires coming from it as opposed to two wires. A standard motor is very easy to run, just hook up the two wires to a positive and negative of a power source and the motor turns. A stepper motor requires positive voltage to be applied to either one or two wires (depends on the stepper) and then the common voltage is cycled rapidly through the other four pins to make the shaft rotate. A stepper motor cannot be directly attached to the outputs of BASIC stamp because the stepper requires 12V to operate. I used an ULN2003 in between the outputs of the BASIC stamp and the 12V required for the stepper motor. A more in depth explanation of how steppers work can be found here and here
The parking stoplight sensor is straight forward to setup. First, attach the photo resistor to the red LED with some tape and use wire to attach it to two points in the breadboard.
The wires attach the photo resistor to the rest of RC time circuit (see the schematic for the circuit). Attach the sensor part to wherever the kids will be walking toward. I duct taped mine to the front door. To set up the sensor, push the button on the top of the stoplight to turn it on. The yellow LED will flash which means it is currently sensing where the point at which it changes to red is. Stand where you think the red light should turn on to activate the circuit. Once the stoplight stops flashing yellow, it has the distance. Walk toward the sensor a few times to make sure it activates when you want it to. If the sensor is sometimes missing you as you walk toward it, it is probably because you walked in between two of the pulses. If it is possible, try to make the sensor so it stays on green by having the sensor sense something farther away. The sensor does not sense very often when it does not see anything to save battery, so if it always sees something in the green range, it will send out pulses more frequently. The sensor also does not reactivate red after a cycle if there are objects close to it. This makes it so the circuit it is activating does not repeat over and over again until nothing is in the red zone.
Parts List with Jameco part numbers.
Part Jameco Cost ULN2003 34278 .39 1N4001 35975 .4 for 10 220 ohm resistor *(2) 690700 $1 for 100 10k ohm resistor 691104 $1 for 100 Photo resistor* Any $1-$2 .01uF* 15231 .67 for 10 BASIC stamp** $99.95
* Only these parts are needed for using the stoplight sensor without the stepper motor.
** You could use a different microcontroller, such as the Arduino chip, however the code provided works with the BASIC stamp.
This schematic shows the connections for the end stop switch, stepper motor, and photo resistor circuit. Since there are many types of photo resistors, the value for sensing the red LED might be different. The DEBUG statement reads what the value of the LED is so make the value in the do while statement so that it is greater than the value.
Get the Basic Stamp Source for this project here.