The Smart Candy Pumpkin 👻🍬

by Uztiota in Living > Halloween

72 Views, 1 Favorites, 0 Comments

The Smart Candy Pumpkin 👻🍬

💕Demo Pumpkin
🧩Final Pumpkin Assembly
affiche variante 2(1920 x 1080).png

The Smart Halloween Candy Pumpkin

Difficulty: ★★★☆☆ (Intermediate)

Build Time: ⏱️ ~4–6 hours

Estimated Cost: 💰 ~25–40 € (depending on parts & print material)


Halloween is that magical time of year when creativity meets fright — and candy flows like never before.

This year, we wanted to make something special — not just another carved pumpkin, but a living, interactive one that surprises everyone who dares to reach inside.

Meet the Smart Candy Pumpkin — a motion-activated, ESP32-powered pumpkin that automatically dispenses candy when you place your hand inside its mouth.

The idea came after seeing kids hesitate before grabbing candy from a regular bowl — so why not make the pumpkin come alive? Inside, a hidden servo and distance sensor detect movement and trigger a rotating wheel that drops a handful of sweets.

We’re two 17-year-old students from Switzerland, both passionate about electronics, 3D printing, and creative projects. The Smart Candy Pumpkin is actually our first full project, and we wanted to make something fun that mixes everything we love — coding, making, and Halloween.

Built with an ESP32, ultrasonic sensor, and a 3D-printed candy wheel, this pumpkin is the perfect mix of electronics, coding, and Halloween fun. It’s designed to be easy to reproduce for makers of all levels — from students to seasoned DIYers.

So, if you’re ready to bring your pumpkin to life (and maybe scare a few trick-or-treaters along the way), let’s get building! 👻

Supplies

20251030_135758~3.jpg

Supplies

Electronic:


Power/Charging

1x Type-C Li-Po Charging Module (TP4056 HW-373 board , 5 V → 4.2 V, 1 A) ¦ Type-C 1PCS

Main charging module for the battery. Safely charges 3.7 V Li-Po cells via USB Type-C.

Aliexpress link:https://shorturl.at/nKeuP

1x 3.7 V Li-Po Battery (10000 mAh)

Powers the ESP32 and servo.

Aliexpress link: https://shorturl.at/S42xR

1x DC-DC Step-Up Converter (5 V output)

Boosts the 3.7 V battery voltage to a stable 5 V for the ESP32 and sensors.

Aliexpress link:https://shorturl.at/hy9fU

1X USB Type-C Cable (or Micro-USB depending on your charger)

Used to charge the Li-Po through the HW-373 board and for code upload if needed.


Control And Electronics ‍

1X ESP32S3 Development Board N16R8 solderless

The brain of the pumpkin! Controls the sensor, servo, and candy dispenser mechanism.

Aliexpress link:https://shorturl.at/64Qph

1X HC-SR04 Ultrasonic Sensor

Detects when a hand enters the pumpkin’s mouth to trigger the candy distribution.

Aliexpress link:https://shorturl.at/7jW49

1X Servo Motor (SG90 or MG90S)

Drives the internal wheel that releases candies.

Aliexpress link:https://shorturl.at/Mjuy7


3D Printing And Hardware


1kg of 3D printing filament(PLA Orange)

→ Custom shell for all electronics.

BambuLab PLA MATTE: https://shorturl.at/Oiv1V

1× Set of BambuLab Magnets D6x2 mm Round Magnet (20PCS) - CA004

→ Keeps pumpkin head perfectly aligned and easy to open.

BambuLab Magnets link


️ Tools:


Soldering station + solder wire spool

Silicone heat-resistant mat (to protect your desk while soldering)

Flux syringe (for clean, shiny solder joints)

Wire cutter / stripper (blue automatic type)

Precision screwdriver set

Tweezers (for small parts)

Small scissors

Heat-shrink tubing assortment (for insulation)

Zip ties or Velcro straps (for neat cable management)

Hot glue gun or double-sided tape (to secure components)

Multimeter (optional but useful for troubleshooting)

  1. Access to a 3D printer

Safety & Preparation

20251030_135848-EDIT~2.jpg

Before bringing your pumpkin to life, let’s make sure everything stays safe — both for you and your workspace.

This project involves electronics, soldering, 3D printing, and Li-Po batteries, so a few precautions go a long way.

Always unplug power before wiring or soldering, and double-check all battery polarities (+/–).

Handle the Li-Po with care — never bend, puncture, or charge it unattended. Place it on a non-flammable surface while charging.

When soldering, wear protective glasses, work in a ventilated area, and use a proper stand for your iron.

For 3D printing, let the parts cool completely before assembly, and trim off any sharp edges or support marks.

💡 Tip: A multimeter is your best friend — always check voltage before powering your ESP32.
⚠️ Warning: Hot glue and Li-Po cells don’t mix! Keep glue away from batteries and wires.


Wiring Overview

circuit_image (9).png

Before starting the build, here’s how every component connects together.

you can find on this link more clearly all the circuit

https://app.cirkitdesigner.com/project/bdcf653b-0cb5-4596-8416-652c75baebec

This wiring diagram shows the layout we’ll assemble in the next steps

Pin Connections

  1. Servo Motor
  2. White→ Pin 14 on the ESP32
  3. Red → 5 V output from the booster
  4. black→ GND output from the booster
  5. Ultrasonic Sensor (HC-SR04)
  6. VCC → 5 V output from the booster
  7. GND → GND output from the booster
  8. TRIG → PIN 16 (blue wire)
  9. ECHO → PIN 15 (yellow wire)
  10. Power System
  11. Battery (3.7 V)HW-373 Type-C charger
  12. Red (+) → B+
  13. Black (–) → B-
  14. HW-373 outputMT3608 booster input
  15. OUT + → VIN + (red)
  16. OUT – → VIN – (black)
  17. 🧠 Tip: Always double-check the polarity (+/–) before powering on. A wrong connection can damage the ESP32 or booster.

⚡Adding the Power Switch

⚡ Step 1 — Adding the Power Switch
circuit_image (5).png

🎥 This step is shown in the time-lapse video — quick and satisfying to watch!

We’re adding a small toggle switch to control power between the battery and the circuit.

  1. 🔪 Trim the switch: it’s a 3-pin toggle — just cut off the third pin (the unused one).
  2. ✂️ Cut the battery’s red wire in half. You now have two ends: one from the battery, one going to the circuit.
  3. 🔧 Strip & tin both ends with a bit of solder.
  4. 🧰 Slide a heat-shrink tube on the battery side before soldering.
  5. 🔥 Solder the battery wire to the left lug, and the other half (to the circuit) on the right lug.
  6. ♨️ Pull the heat-shrink over both joints and shrink it with a lighter — quick passes, no flames on the Li-Po!

✅ That’s it! You now have a clean little power switch inline with the battery.

🔋Connecting the Charger to the DC Booster

circuit_image (4).png
🔋 Step 2 — Connecting the Charger to the DC Booster

🎥 Shown in a short time-lapse — quick and clean wiring!

Now we’re linking the Type-C charging module to the DC-DC booster, so the battery power can be stepped up to 5 V for the circuit.

  1. ✂️ Prepare two short wires — just long enough to go from the charger to the booster.
  2. 🧵 Strip and tin both ends of each wire.
  3. ⚙️ On the charging module, solder one wire to each outer pad (⚠️ not the BAT+ / BAT– pads — use the input/output side).
  4. 🔌 Then solder those two wires to the VIN + and VIN – pads on the DC booster.
  5. ⚠️ Double-check polarity: + → +, – → – before powering anything.
  6. 🔧 Plug in a USB-C cable to the charger, then use a small screwdriver to slowly turn the adjustment screw on the DC booster until the output voltage reads 5.0 V (you can check with a multimeter).
  7. 🔥 Once everything is correct, add heat-shrink tubing if needed for insulation.

✅ That’s it — your charger and booster are now properly linked and delivering a clean 5 V output for your pumpkin!

🔋Connecting the Battery to the Charging Module

🔋 Step 3 — Connecting the Battery to the Charging Module
circuit_image (6).png

🎥 Shown in a short time-lapse — note: the power switch isn’t visible in this clip!

Now we’re soldering the Li-Po battery directly to the Type-C charging board.

  1. ⚠️ Heads-up: the two-position power switch you added earlier doesn’t appear in this video. Don’t worry, it’s still part of the build!
  2. 🔧 Take the battery leads (red = +, black = –).
  3. 🧵 Tin both ends, then solder red → B+ and black → B– on the charging module.
  4. 🧰 Add heat-shrink tubing before soldering, then slide it over the joints.
  5. 🔥 Use a lighter to shrink the tubing carefully — short passes only, keep the flame away from the Li-Po!

✅ Done! The battery is now safely connected to the charger and ready to power the system through the switch.

🌐 Wiring the Ultrasonic Sensor

🌐 Step 4 — Wiring the Ultrasonic Sensor
circuit_image (7).png

🎥 Shown in a fast time-lapse — this step is all about prepping clean, removable connections!

We’re now wiring the ultrasonic distance sensor (HC-SR04) with a neat detachable cable setup.

  1. ✂️ Prepare the cable: use a 4-wire ribbon (red, black, yellow, blue) with a female connector end.
  2. Keep it short — just enough to reach your ESP32 later.
  3. 🧵 Tin all four wires on the open side of the ribbon.
  4. 🔥 On the ultrasonic sensor, add a bit of solder to the four pins (VCC, Trig, Echo, GND) to remove the default header.
  5. ⚙️ Solder the 4 wires directly onto the sensor:
  6. 🔴 VCC → red
  7. GND → black
  8. 🟡 Echo → yellow
  9. 🔵 Trig → blue
  10. 🔩 Now take 4 small male-to-male pins, tin the shorter side, and solder each color wire to its matching pin.
  11. 🧰 Slide heat-shrink tubing over every joint, then shrink them for a clean finish.

✅ You now have a plug-and-play ultrasonic sensor cable — the male pins fit right into the female connector from your 4-wire ribbon.

⚙️Preparing the Servo Connection

⚙️ Step 5 — Preparing the Servo Connection
circuit_image (3)122.png

🎥 Another short time-lapse — same method as for the ultrasonic sensor!

Now we’re wiring the servo motor so it can easily plug into the circuit later.

  1. ✂️ Cut three short wiresblack, red, and yellow.
  2. 🧵 Strip and tin both ends of each wire.
  3. 🔩 Take three male-to-male pins, and solder the wires to the short side of the pins (just like in the previous step).
  4. 🧰 Slide heat-shrink tubing on each one and shrink it with a lighter to insulate and clean the finish.
  5. ⚙️ On the servo side, match the colors:
  6. Black → Black
  7. 🔴 Red → Red
  8. White → Yellow

✅ You now have a detachable 3-pin connector ready to plug straight into your servo motor.

🔴Power Wiring: Servo + Sensor to the Booster

🔴 Step 6 — Power Wiring: Servo + Sensor to the Booster
circuit_image (8).png

🎥 Time-lapse available on YouTube — quick view of the full wiring process!

Here we’re connecting the power lines (5 V and GND) for the servo and the ultrasonic sensor to the DC-DC booster output.

  1. ✂️ Take the red wire from the servo, the red wire from the sensor, and add a short extra red wire (for the ESP32 later).
  2. 🧵 Strip and tin the loose ends, then twist all three red wires together.
  3. 🔥 Slide a small heat-shrink tube behind them, then solder the bundle onto the V-OUT + pad of the DC booster.
  4. 🧰 Add a larger heat-shrink over everything to cover and protect the joint.

Then repeat the exact same process for GND:

  1. Use the black wires (servo, sensor, and an extra one for the ESP32).
  2. Twist them together, tin, and solder onto V-OUT –.
  3. Finish with heat-shrink tubing — small on the wires, large over the group.

✅ Now the servo, sensor, and ESP32 will all share the same 5 V and ground from the booster.

🧠Wiring Everything to the ESP32

🧠 Step 7 — Wiring Everything to the ESP32
circuit_image (10).png

🎥 Full time-lapse available — this part shows all the final soldering to the ESP32 board.

Now that all the power lines are ready, it’s time to connect the ultrasonic sensor and servo directly to the ESP32.

  1. 🔵 Trigger (blue wire)GPIO 16
  2. 🟡 Echo (yellow wire)GPIO 15
  3. 🟡 Servo signal (yellow wire)GPIO 14

👉 Start by tinning each wire, then insert it gently through the corresponding hole on the ESP32 and solder from the back side.

  1. 🔌 Take the two small wires you previously soldered on the V-OUT of the DC booster (the extra red and black ones).
  2. 🔴 Red → 5V pin on the ESP32
  3. Black → GND pin (right next to it)
  4. ✂️ Once everything is soldered, trim the wire ends from the bottom so they don’t stick out.

⚠️ Tip: Make sure all connections are on the same side of the board for a clean, flat assembly — don’t mix front/back sides.

✅ Your ESP32 is now fully wired and ready to power and control the pumpkin!

💻Uploading the Code to the ESP32

20251108_235757~2.jpg
20251108_235634~2.jpg

Now that everything’s wired and assembled, it’s time to give your pumpkin a brain 🧠🎃

Don’t worry — it’s quick and beginner-friendly!

⚙️ 1) Install Arduino IDE

If you don’t already have it, download and install the latest version of the Arduino IDE from the official website.

🧩 2) Add ESP32 board support

To let Arduino recognize your ESP32, you need to add its package:

  1. Open Arduino IDE → File → Preferences.
  2. In Additional Boards Manager URLs, paste this link:

https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
  1. Click OK, then close the window.

⚡ 3) Install the ESP32 package

  1. Go to Tools → Board → Boards Manager...
  2. Search for esp32
  3. Install the package by Espressif Systems

Once it’s done, go to Tools → Board → ESP32 Arduino → ESP32S3 Dev Module.

Then plug your board in via USB on THE USB ONE and select the correct port under Tools → Port.

📚 4) Install the required libraries

Our project uses two simple, ESP32-friendly libraries:


#include <ESP32Servo.h> // by Kevin Harrington & John K. Bennett — ESP32-compatible Servo control
#include <Ultrasonic.h> // by Erick Simões — simple ultrasonic helper for ESP32

You can install both directly from the Arduino Library Manager:

Sketch → Include Library → Manage Libraries... → Search → “ESP32Servo” and “Ultrasonic”, then click Install on each.

🔧 5) Open and configure the code

  1. Open the provided Smart_Candy_Pumpkin.ino file.
  2. Double-check that your pins match your build:

SERVO_PIN = 14
TRIG_PIN = 16
ECHO_PIN = 15
  1. You can also tweak DIST_THRESHOLD (trigger distance) and the servo angles if needed — everything’s commented inside the code.

🚀 6) Upload it!

Click Upload (▶).

If the upload doesn’t start, hold the BOOT (or IO0) button on your ESP32 until it begins flashing, then release it.

Once done, open the Serial Monitor (115200 baud) to test:

  1. When you move your hand inside the pumpkin’s mouth, the servo should spin and drop candy. 🍬
  2. If it moves the wrong way, just swap the open/close angles in the code comments.

That’s it! Your ESP32 is now programmed.

🎃3D Printing the Pumpkin

rendu 9 effet.png
20251109_024523~2.jpg

The pumpkin model is split into seven printable parts, designed for easy assembly and a clean finish.

All pieces are printed in orange PLA, except the stem (green) and the servo wheel (black), which add a nice color contrast.

🧩 Parts list

  1. 🟠 Bottom Base — holds the battery, ESP32, and lower mouth section.
  2. 🟠 Inner Cover — hides the electronics and keeps the inside tidy.
  3. 🟠 Mid-Mouth Section — contains the servo, ultrasonic sensor, and candy chute.
  4. Servo Wheel (Rotating Disk) — attaches to the servo horn and releases the candies. Print this one in black (or any color you like).
  5. 🟠 Upper Mouth Section — includes the eyes and top of the mouth.
  6. 🟠 Candy Funnel Top — where you pour the candies in.
  7. 🟢 Stem Cap — small green piece glued on top (the pumpkin stem).
  8. 🟠 Alignement Connector — print 6 times.

🧰 Printing stats

  1. ⏱️ Total print time: ≈ 22 hours on a Bambu Lab P1S
  2. 🧵 Filament used: ≈ 800 g of PLA
  3. 📏 Layer height: 0.16 mm
  4. 🪶 Plate: Textured build plate
  5. 🧱 Supports: use normal supports for best surface quality,
  6. but disable supports inside the cable management area of the Bottom Base — otherwise, you won’t be able to pass the wires through.

📦 Files available

  1. .STL files for all 8 parts
  2. .3MF project file ready for Bambu Studio
  3. Preconfigured MakerWorld profile for all Bambu Lab printers — follow the MakerWorld link provided to print directly with recommended settings.

https://makerworld.com/fr/models/1973808-the-smart-candy-pumpkin?from=search#profileId-2122622

✅ Once all parts are printed, you’re ready to start assembling and bring your Smart Candy Pumpkin to life! 👻

🪄Gluing the Pumpkin Stem and Placing the Magnets

20251108_164830~2.jpg
20251108_170053~2.jpg
20251108_164855~2.jpg

Start by taking the small green stem and glue it right in the center of the top cap of the pumpkin.

Use super glue (or any strong adhesive you have) — a small drop is enough. Press firmly for a few seconds and let it dry.

✅ That’s it — your pumpkin now has its stem! 🌱

🔩 On the underside of this top cap, you’ll see small round holes — these are for the magnets.

⚠️ Important: before inserting magnets, make sure you put them on the correct side!

To check this:

  1. Take two magnets and stick them together — this shows which faces attract.
  2. Then slide one magnet into the hole (it should fit snugly).
  3. For the matching part, use the second magnet (still attached) to find the correct orientation so the pieces attract, not repel.
  4. Once you’ve found the right side, separate them gently and insert the second magnet the same way.

No glue needed — the fit should hold them in place perfectly.

🍬Assembling the Candy Funnel With the Upper Mouth Section

20251108_165802~2.jpg
20251108_165836~2.jpg

In this step, we’ll connect the Candy Funnel Top with the Upper Mouth Section — the 3D-printed piece that includes the top of the mouth and the upper part of the eyes.

Take your time here; this is one of the most important assembly stages before final fitting.

  1. ⚙️ Place the servo motor (“the brain”) into its dedicated slot inside the Mid-Mouth Section.
  2. ⚫ From the other side, insert the black Servo Wheel and secure it using the screw provided with the servo.
  3. ⚠️ Don’t overtighten — the servo needs to rotate freely, so stop as soon as it holds firmly.
  4. 📡 Insert the ultrasonic distance sensor into its opening.
  5. Pass the wires through the small cable hole right behind it.
  6. Add a small piece of double-sided tape under the sensor to keep it in place. (No tape under the servo!)
  7. 🧴 Once both components are installed, take the Candy Funnel Top and align it with the Upper Mouth Section.
  8. 🧩 Insert the plastic connection cylinders (included in the files) into the larger holes where both parts meet.
  9. 💪 Apply a small amount of glue on the cylinders, then press the two parts together firmly until the glue starts to set.

⚠️ Important: Don’t attach this assembly to the rest of the pumpkin yet — this section will later hook onto the next printed part during the final build.

✅ When finished, you should have the servo and sensor installed, wires neatly routed, and the Candy Funnel Top securely glued to the Upper Mouth Section.

🧵Routing the Wires to the Bottom Base

20251108_174126~2.jpg

In this step, we’ll pass all the servo and ultrasonic sensor wires down into the Bottom Base, through the built-in cable tunnel in the pumpkin’s wall.

  1. 🎣 Take a piece of fishing line (or any thin, strong wire).
  2. 🪡 Tie the servo and sensor wires together securely at one end of the fishing line.
  3. 🕳️ From the Bottom Base, feed the fishing line up through the cable passage until it reaches the opening near the Mid-Mouth Section.
  4. 🧲 Gently pull the fishing line back down, bringing all the wires with it.
  5. Do it slowly — the passage is tight, so go steady to avoid snagging or pulling connectors loose.
  6. 🧰 Once the wires are out at the bottom, tape or glue them along the top edge (inside the pumpkin) to keep them neat and out of sight.

✅ That’s it — your wires are now routed cleanly from the servo and sensor to the Bottom Base, ready for the final connections.

⚡Mounting the Electronics in the Bottom Base

20251108_175154~2.jpg
20251108_175208~2.jpg
20251108_175313~2.jpg

We’re now setting up all the electronics inside the Bottom Base, the core of your Smart Candy Pumpkin.

  1. 🔋 Stick the battery in the center of the base using double-sided tape.
  2. Route the cables behind the battery so they stay flat and tidy.
  3. 🧠 Place the ESP32 at the very bottom and fix it with double-sided tape to keep it stable.
  4. 🔌 Insert the power switch into its dedicated side hole.
  5. Make sure it’s well aligned, just like shown in the photo.
  6. ⚙️ Mount the charging module (Type-C) into its slot and secure it with tape.
  7. Align the USB-C port with the external hole for easy charging.
  8. Stick the DC-DC booster next to the charger with double-sided tape.
  9. 🧩 Once all components are in, gently flatten the wires along the walls for a clean finish.

⚠️ Tip: There’s a photo showing the full setup — use it as a visual guide for positioning and cable management (even if ours isn’t perfect, it clearly shows where everything goes!).

✅ When done, your battery, ESP32, switch, charger, and booster should all be securely placed and ready for the final assembly.

🧩Final Pumpkin Assembly

🧩Final Pumpkin Assembly
20251109_030910.jpg

This is the very last step of the build — time to bring all the main parts together 🎃

  1. 🧰 Start by placing the Inner Cover — the small flat plate that hides the battery and wiring.
  2. It rests on the small inner ledge inside the Bottom Base.
  3. ⚠️ Don’t glue this piece — it simply sits there so you can remove it later if needed.
  4. 🧱 Take the Bottom Base (the part that holds the battery, ESP32, charger, and switch) and the Mid-Mouth Section (the one with the servo and sensor).
  5. 🧴 Insert the plastic connection cylinders into the large holes between these two parts.
  6. 💪 Apply a small drop of glue on each cylinder, then carefully press both parts together until they’re well aligned.
  7. Hold a few seconds so the glue starts to set.

That’s it — your pumpkin body is now fully assembled! 👻

🎉The Pumpkin Comes to Life!

Image.png

And that’s it — your Smart Candy Pumpkin is finally complete! 🎃✨

Everything is assembled, the wiring and code are done, and your spooky creation is ready to go.

Now just fill the funnel with M&M’s or your favorite candies, flip the switch, and let the magic happen 🍬🤖

You’ve built a full Halloween robot — great job! 👏


This was actually our very first project on Instructable, so we really tried to make it as clean, fun, and easy to follow as possible.

💬 Your feedback means a lot to us — don’t hesitate to share your thoughts or ideas for improvement!

If you enjoyed this project, you can:

Support us on Buy Me a Coffee — it really helps us make more awesome builds!

💬 Leave a comment below and tell us how your version turned out.

❤️ Like this post and share it with your friends — let’s spread some Halloween tech fun!

💫 Acknowledgments

rendu 5 effet.png

Before closing, we want to give a few well-deserved shout-outs to the people who made this project even cooler 👇

  1. 🎨 Big thanks to our Blender wizard, Kwama Muhoto Tevin, for creating the amazing 3D renders and visuals that bring the pumpkin to life!
  2. 🔧 Thanks to the ELN department at CPNE for helping us out with tools and basic materials during the build.
  3. 🏍️ And a huge thank-you to Alessio Castorina for always being there to help (and for his ultra-fast deliveries!).

You all played a part in making this Smart Candy Pumpkin possible — thank you! 🎃