Pololu Blog »
Candy bowl surprise
Anyone who has gone trick-or-treating has seen the house that puts a bowl of candy on the front porch and knows that there are those greedy trick-or-treaters who take more candy than they are supposed to. Well, if you are that person who puts the bowl of candy out on your front porch, you can make trick-or-treaters think twice before they take more than one piece of candy. In this project, I actuate a severed arm to slap down at the candy bowl whenever someone goes to reach into it.
Implementation
This project takes the basic idea behind Jon’s Ghastly gas ghost (a Maestro using the input of a distance sensor to trigger a servo movement) and adapts it to give trick-or-treaters a surprise. Like Jon, I used a Micro Maestro USB Servo Controller and the Sharp GP2Y0A02YK0F Analog Distance Sensor 20-150cm. However, I used a Power HD High-Torque Servo 1501MG since I wanted a servo with more torque to work against the long lever arm provided by the Halloween prop arm. I built a structure from some 1/4"-thick wood to elevate the arm so it would come down on top of the bowl. I had part of the structure extend out below the candy bowl to stabilize the base and to allow the candy bowl to weigh down the setup. To bond the structure together, I used wood glue. I also cut a small thin strip of wood that I used to connect the servo horn to the arm. I attached the piece of wood to the servo horn using the screws that were included with the servo. A 6.0 V battery pack powers the system, and I used a 5V, 500mA Step-Down Voltage Regulator D24V5F5 since the Micro Maestro’s regulator can’t supply enough current for the distance sensor, I also soldered a 100 uF capacitor on the Sharp sensor’s power leads to help with noise.
For the script on the Maestro, I started with Jon’s code from the Ghastly gas ghost project. I only changed the servo rest position and the length of time that the servo is in the down position. Here is the simple script that is running on the Maestro:
8000 1 servo # initializes servo position 1000 delay # waits 1 second for servo to reach position 0 1 servo # saves power by not sending pulses to servo begin 0 get_position 250 greater_than if # check for trick-or-treater 4000 1 servo # swing arm down 3000 delay # wait 3 seconds 8000 1 servo # return to initial position 1000 delay 0 1 servo # power saving 30000 delay # wait 30 seconds before allowing the arm to swing again endif repeat
Parts list
- Micro Maestro USB Servo Controller
- Power HD High-Torque Servo 1501MG
- Sharp GP2Y0A02YK0F Analog Distance Sensor 20-150cm
- a 100 uF capacitor (anything over 10 uF would have been fine)
- 3-pin JST cable for Sharp distance sensors (with female crimp pins so it can plug into the Maestro)
- 1×1 crimp connector housing (for use with the cable above)
- battery pack
- 5V, 500mA Step-Down Voltage Regulator D24V5F5
- wood
- double-sided tape
- wood glue
- severed arm Halloween prop
Additional thoughts
It is probably a good idea to add decorations to hide the electronics from unsuspecting trick-or-treaters. More importantly, you’ll want to make sure to have the sign so the arm looks like it is there to hold it and not to try and deny people candy. You could even remove the arm altogether and replace it with a larger, more rigid candy sign. Whatever you use, you should make sure that the arm won’t actually hurt anyone (your neighbors probably won’t take it too well if your props are harming them). The particular setup I have doesn’t exert much force if it happens to encounter someone’s arm because the servo doesn’t move that fast, and the long arm limits the amount of torque the servo can exert.