You are on page 1of 12

instructables

COVID-friendly Trick-or-treating Jack-o'-Lantern Using Arduino

by alexoort

As Halloween is right around the corner but coronavirus cases are rising throughout the world, I thought that it
would be useful to make a Jack-o'-lantern that drops candy whenever you get close to it, to avoid the usual human
contact during trick or treating.

To do this, I used an Arduino Nano, an ultrasonic sensor, a servo motor, and a 3D printed pumpkin!

Supplies:

Electronics:

Arduino Nano
Ultrasonic sensor
Servo motor
Jumper wires
3D printer & lament

Tools & other:

Soldering iron
Spray paint
Hot glue gun
String/shoelace (optional)
Sandpaper
Drill with a wire brush (optional)
Cotton swab/toothpick

COVID-friendly Trick-or-treating Jack-o'-Lantern Using Arduino: Page 1


https://youtu.be/bqFVJQitPzI

Step 1: The Pumpkin: Design

Instead of using an actual pumpkin, I decided to 3D There's also small rings at the top which will allow us
print one, as this would allow for the moving to hang it.
mechanism necessary for dropping the candy.
If you would like to modify the design, please go
I designed the Jack-o'-lantern using Tinkercad, and I ahead; however, keep in mind that the eyes have to be
have attached the STL les below. The Jack-o'-lantern 1cm apart and have a diameter of 1.6, or else the
consists of eyes, a nose, a mouth, as well as a lid at the ultrasonic sensor will not t. Also, make sure that the
top (to put in the candy) and a hinge at the bottom hinge mechanism will work in real life.
that should open whenever someone approaches.

COVID-friendly Trick-or-treating Jack-o'-Lantern Using Arduino: Page 2


View in 3D Download

https://www.instructables.com/ORIG/FW5/TCOE/KGXP40EV/FW5TCOEKGXP40EV.stl

View in 3D Download

https://www.instructables.com/ORIG/FOM/VSVL/KGXP40LZ/FOMVSVLKGXP40LZ.stl

View in 3D Download

https://www.instructables.com/ORIG/F73/Q19D/KGXP48FU/F73Q19DKGXP48FU.stl

Step 2: Pumpkin: 3D Printing

For the 3D printing, I used the Ultimaker 2 from my also important to check whether you have enough
school, but you can use whichever printer you have lament on your spool, as each part of the pumpkin
available. However, make sure to adjust the slicer requires roughly 100 grams.
settings and enable support (this allows the printing
of overhangs), or else the print will fall apart while Once the printing has nished, you will have to
printing. I would also recommend printing the sides remove the support material. To do this, I used some
of the pumpkin as shown in the picture above, or else pliers, a knife and a screwdriver. Some support
the lament will not properly stick to the print bed. material could not be removed using this method, so I
used some sandpaper and a drill wire brush to
I decided to print the pumpkin in two parts, as this remove most of what was left. However, it's ne if your
would require less support material, and also make it pumpkin is not completely smooth since real
easier to attach the electronics inside. pumpkins aren't perfect either.

For my lament, I simply used grey PLA that I had Also, if you accidentally break the hinge on the
bought from Amazon. If you'd like though, you could pumpkin, do not worry at all; simply add some hot
also use orange lament so that you don't have to glue and stick it on again.
paint the parts later on. Before starting the print it is

COVID-friendly Trick-or-treating Jack-o'-Lantern Using Arduino: Page 3


Step 3: Painting

COVID-friendly Trick-or-treating Jack-o'-Lantern Using Arduino: Page 4


Once you have nished removing the support recommend placing the pumpkin and the other parts
material from your pumpkin, it's time to paint! on a piece of old cardboard or wood so that you don't
paint your garden orange.
An easy option is just using orange spray paint;
however, if you want to decorate your pumpkin even I decided to paint the pumpkin as well as the servo
further and make it a zombie pumpkin, you could use motor so that it is camou aged and not very visible.
acrylics.
After you have applied a coat of paint, leave the parts
If you are using spray paint, make sure that you are outside for a few hours to let them properly dry.
outside when you paint the parts. I would also

COVID-friendly Trick-or-treating Jack-o'-Lantern Using Arduino: Page 5


Step 4: Circuit

COVID-friendly Trick-or-treating Jack-o'-Lantern Using Arduino: Page 6


As you can see above, the circuit for this project is would recommend soldering the parts together, as
quite simple. You simply need to connect the this will prevent a jumper wire disconnecting.
ultrasonic sensor and the servo motor to the Arduino. However, please don't solder the Servo motor yet, or
For this project, it's better to use an Arduino Nano due you will have to desolder it later on.
to its smaller size. If you want to use an Arduino UNO,
then you may have to edit the 3D model somewhat. Before we move on to the code, however, it's
Since the servo motor pulls too much power from the important to understand how an ultrasonic sensor
Arduino, an external power supply is needed, which works. Essentially, it sends out ultrasonic signals and
can simply be a USB cable. To be able to connect the measures the time it takes for the signals to return.
USB to the Servo, you will want to cut the USB cable Ultrasound is a type of sound that has such a high
so that you can see 4 smaller wires. Red is +5V and pitch that humans can't hear it. However, like sound,
black is ground. The ground of some cables will it bounces o objects. Therefore, if there is an object
sometimes be wrapped around the other wires like a nearby, the signals will bounce o and quickly return
case. You can ignore the green and white wires, or just to the sensor. The farther away from the body, the
cut them o . more time it will take for the ultrasonic signals to
arrive back at the ultrasonic sensor.
If you want to make the project more permanent, I

Step 5: The Code

COVID-friendly Trick-or-treating Jack-o'-Lantern Using Arduino: Page 7


Just like the circuit diagram, the code for the project By using the speed of sound, this duration is turned
is relatively straightforward. into a distance, in cm. If the distance is smaller than
15 cm, then the Arduino moves the Servo motor, and
In the setup, the servo motor is initialized and the trig opens the 'door' at the bottom of the pumpkin,
and echo pins are declared as output and input dropping candy. The Arduino then waits for 1 second
respectively. before restarting the loop.

In the loop, the trig (ping) pin is set to LOW, and Now you will want to upload the code to your
quickly after it is set to HIGH. The Arduino then Arduino. If you are using a Nano and you are having
measures the time it takes for the echo pin to receive problems uploading, go to Tools > Processor and
the ultrasonic wave, and stores this value in the select 328P (Old bootloader) on the Arduino IDE.
duration variable.

Download

https://www.instructables.com/ORIG/FIA/LNGI/KGXP3YLR/FIALNGIKGXP3YLR.ino

Step 6: Assembly

We're almost there! Now it's time to put everything Now that all of the necessary components are inside,
together. you can close o the pumpkin. Add hot glue to the
edge of one side of the pumpkin and then bring the
First, upload the code to the Arduino. Then, using hot two sides together until the glue has solidi ed. You
glue, stick the Arduino to the left side of the pumpkin will now want to place the small 'door' between the
(the one that has two teeth), and make sure that you three hinges on the pumpkin. Then, cut o the ends
don't cover the hole for the Servo motor cables. Pass of a cotton swab and insert it through the holes on
the USB cable for the Arduino through the square the hinges. Cut o the parts that stick out and then
hole (on the other side of the pumpkin) and connect it glue the ends of the swab to the hinge on the
to the Arduino. pumpkin, so that the door can still move freely.

Next, insert the ultrasonic sensor through one of the Glue the servo motor to the bottom of the pumpkin,
eyes on the pumpkin, so that they stick out on the so that the Servo horn (the 'pointer' on the Servo
outside, as shown in the picture above. Now connect motor) is aligned with the 'door' (as shown in the
the ultrasonic sensor to the Arduino. pictures above). To improve the opening-and-closing
mechanism, I added a resistor (you could use
Next, connect the repurposed USB cable to the Servo something else if you like) to the end of the horn and
motor's + and - pins. Now connect the ground (-) of then glued the resistor to the 'door', as shown.
the servo motor to the Arduino's ground. Finally,
connect the signal pin on the Servo motor to digital If you power up the servo motor and the Arduino, it
pin 9 (Make sure that you pass these cables through should work!
the small hole at the back of the pumpkin).

COVID-friendly Trick-or-treating Jack-o'-Lantern Using Arduino: Page 8


COVID-friendly Trick-or-treating Jack-o'-Lantern Using Arduino: Page 9
COVID-friendly Trick-or-treating Jack-o'-Lantern Using Arduino: Page 10
Step 7: Set It Up

Woohoo! The Jack-O-Lantern itself is nished. Now In terms of candy, I used wrapped chewing gum, but
you just have to set it up. you could of course use other kinds of treats as well.
Before you buy a lot of candy though, make sure that
I decided to hang it from the beams on my porch, but it will t through the opening at the bottom of the
feel free to get creative. I powered both the Servo and pumpkin.
the Arduino with power banks, but you can also
power them from the wall, or your laptop. Alright, that should be it! Good luck!

https://youtu.be/bqFVJQitPzI

COVID-friendly Trick-or-treating Jack-o'-Lantern Using Arduino: Page 11


That's a fun idea :)

COVID-friendly Trick-or-treating Jack-o'-Lantern Using Arduino: Page 12

You might also like