Maker.io main logo

Remote Control Candy Dispenser Ghost

2025-10-14 | By SparkFun Electronics

License: See Original Project 3D Printing Circuit Playground

Courtesy of Adafruit

Guide by Ruiz Brothers and Liz Clark

Overview

 

For social distant trick or treating, we thought we’d make a BLE controlled servo claw using the Circuit Playground Bluefruit.

We put our project on this flying ghost prop we got from our local Halloween shop.

It moves up and down along a rope that's strung across our porch.

We tied one end to a tree and the other to a lamp post on the side of the house.

The servo is triggered using our mobile phone with the Bluefruit connect app.

3d_printing_hero-drop

3d_printing_hero-claw-loop

This is a 3d printed claw gripper that we designed to hold a small bag of candy.

We think this is a fun way to give out candy that could be adapted for all sorts of projects.

The BLE libraries for Circuit Python makes it easy to control servos using the Bluefruit app.

In the code, the up and down buttons are set up to trigger the servo when they’re pressed.

The angle of the servo is tuned for the gripper so it doesn’t stress out the motor.

In the Bluefruit app you can press the up and down buttons to open and close the gripper.

We think this is a quick and easy way to make a BLE controlled servo project.

3d_printing_ghost-drop-loop

3d_printing_assembled-claw-loop

3d_printing_ghost-drop-loop

Parts

Circuit Diagram

The diagram below provides a visual reference for wiring of the components. This diagram was created using the software package Fritzing.

Adafruit Library for Fritzing

Use Adafruit's Fritzing parts library to create circuit diagrams for your projects. Download the library or just grab individual parts. Get the library and parts from GitHub - Adafruit Fritzing Parts.

fritzing_1

Connect the Circuit Playground Bluefruit to the servo's wires as shown in the diagram above.

  • Red goes from VOUT to servo red voltage wire

  • Black goes from GND to servo brown ground wire

  • Yellow goes from A3 to servo yellow signal wire

CircuitPython on Circuit Playground Bluefruit

Install or Update CircuitPython

Follow this quick step-by-step to install or update CircuitPython on your Circuit Playground Bluefruit.

Download the latest version of CircuitPython for this board via circuitpython.org

Click the link above and download the latest UF2 file.

Download and save it to your Desktop (or wherever is handy).

click_2

Plug your Circuit Playground Bluefruit into your computer using a known-good data-capable USB cable.

A lot of people end up using charge-only USB cables and it is very frustrating! So, make sure you have a USB cable you know is good for data sync.

Double-click the small Reset button in the middle of the CPB (indicated by the red arrow in the image). The ten NeoPixel LEDs will all turn red, and then will all turn green. If they turn all red and stay red, check the USB cable, try another USB port, etc. The little red LED next to the USB connector will pulse red - this is ok!

If double-clicking doesn't work the first time, try again. Sometimes it can take a few tries to get the rhythm right!

(If double-clicking doesn't do it, try a single-click!)

click_3

You will see a new disk drive appear called CPLAYBTBOOT.

Drag the adafruit_circuitpython_etc.uf2 file to CPLAYBTBOOT.

drag_4

drag_5

The LEDs will turn red. Then, the CPLAYBTBOOT drive will disappear, and a new disk drive called CIRCUITPY will appear.

That's it, you're done! :)

drive_6

Code

code_7

Once your CPB is set up with CircuitPython, you'll also need to add some libraries. Follow this page for info on how to download and add libraries to your CPB.

From the library bundle you downloaded in that guide page, transfer the following library folders onto the CPB board's /lib directory:

  • adafruit_ble

  • adafruit_bluefruit_connect

  • adafruit_motor

Before continuing, please be sure your board's CIRCUITPY drive has a /lib folder with the three folders listed above. Please do not copy the files out of those folders to put in the /lib directory.

Text Editor

Adafruit recommends using the Mu editor for using your CircuitPython code with the Circuit Playground Bluefruit boards. You can get more info in this guide.

Alternatively, you can use any text editor that saves files.

3d_printing_code-wide-loop

Code.py

Copy the code below and paste it into Mu. Then, save it to your CPB as code.py. Alternatively click Download: Project Zip or code.py links to download the file to your computer.

Download Project Bundle

Copy Code
# SPDX-FileCopyrightText: 2020 Liz Clark for Adafruit Industries
#
# SPDX-License-Identifier: MIT

import time
import board
import pwmio
from adafruit_motor import servo
from adafruit_bluefruit_connect.packet import Packet
from adafruit_bluefruit_connect.button_packet import ButtonPacket
from adafruit_ble import BLERadio
from adafruit_ble.advertising.standard import ProvideServicesAdvertisement
from adafruit_ble.services.nordic import UARTService

ble = BLERadio()
uart = UARTService()
advertisement = ProvideServicesAdvertisement(uart)

pwm = pwmio.PWMOut(board.A3, duty_cycle=2 ** 15, frequency=50)

my_servo = servo.Servo(pwm)

while True:
    print("WAITING...")
    # Advertise when not connected.
    ble.start_advertising(advertisement)
    while not ble.connected:
        pass

    # Connected
    ble.stop_advertising()
    print("CONNECTED")

    # Loop and read packets
    while ble.connected:
        if uart.in_waiting:
            packet = Packet.from_stream(uart)
            if isinstance(packet, ButtonPacket):
                #  if buttons in the app are pressed
                if packet.pressed:
                    if packet.button == ButtonPacket.DOWN:
                        print("pressed down")
                        for angle in range(90, 170, 90):  # 90 - 170 degrees, 90 degrees at a time.
                            my_servo.angle = angle
                            time.sleep(0.05)
                    if packet.button == ButtonPacket.UP:
                        print("pressed up")
                        for angle in range(170, 90, -90): # 170 - 90 degrees, 9 degrees at a time.
                            my_servo.angle = angle
                            time.sleep(0.05)
    # Disconnected
    print("DISCONNECTED")

View on GitHub

Bluetooth App

This project uses the Adafruit Bluefruit LE connect app (available free for Android and iOS) to trigger the servo. It uses the control pad to open and close the servo claw. If you haven't downloaded the app yet, use the button below to install it on your mobile device.

3d_printing_app-wide-loop

Download BLE Connect App iOS

Download BLE Connect App for Android

Connect to Circuit Playground Bluefruit

Turn on the Circuit Playground Bluefruit by either connecting it via USB to your computer or with the 500mAh battery.

Using Bluefruit LE Connect App

Open the Bluefruit LE connect app and locate the device named CIRCUITPY and tap the connect button. Locate and tap on Controller. Under module, tab on Control Pad.

Use the UP and DOWN arrow buttons to trigger open and close the servo claw.

3D Printing

Parts List

STL files for 3D printing are oriented to print "as-is" on FDM style machines. Parts are designed to 3D print without any support material. Original design source may be downloaded using the links below.

  • servo-holder.stl

  • arm-sm.stl

  • arm-lg.stl

  • case-cover.stl

  • case-btm.stl

parts_8

Edit BLE Claw

Download BLE Claw STLs

Slicing Parts

Slice with setting for PLA material. The parts were sliced using CURA using the slice settings below.

PLA filament

215c extruder

0.2 layer height

10% gyroid infill

60mm/s print speed

60c heated bed

Assembly

CPB wires

Follow the circuit diagram and tin and solder wires to each pad on the Circuit Playground Bluefruit.

Servo Wires

Shorten the cables on the servo to keep the circuit tidy.

Use heat shrink to insulate the connections.

wires_9

wires_10

Servo Hardware

An M3 nut is place in the servo holder part.

The servo is press fitted into the holder with the shaft fitted through the opening.

The arm of the claw is fitted over the shaft and secured with one of the servo horns.

Servo Horns

The included servo horn press fits over the claw. Use the shorter included screw to secure the horn and claw.

Second Arm

The other arm is secured to the mounting hole using an M3 screw and nut.

horns_11

horns_12

horns_13

horns_14

Attach Servo to Case Lid

The top cover of the case is secured to the servo holder using M2.5 screws.

The Circuit Playground Bluefruit sits in the enclosure with the wires fitted through the hole in the cover.

attach_15

Case

The LiPo battery is place in the middle of the case. Coil the wires around the case. Fit the wire over the vertical cutout on case.

Lid

Place the lid over the case. Thread the wires on the Circuit Playground Bluefruit through the Lid.

lid_16

lid_17

Case Screws

The top cover is secured to the enclosure using M3 screws.

The servo can then be plugged into the Circuit Playground Bluefruit.

Attach Case

The enclosure is secured to the battery cover of the flying ghost using double-sided foam tape.

case_18

case_19

Complete!

3d_printing_loop-claw-heroc

3d_printing_ghost-drop-loop

Mfr Part # 4333
CIRCUIT PLAYGROUND BLUEFRUIT BLE
Adafruit Industries LLC
21,40 €
View More Details
Mfr Part # 1143
SERVOMOTOR RC 5V HIGH TORQUE
Adafruit Industries LLC
8,54 €
View More Details
Mfr Part # 4685
BLACK NYLON SCREW AND STAND-OFF
Adafruit Industries LLC
14,54 €
View More Details
Mfr Part # 4111
CABLE A PLUG TO MCR B PLUG 3.28'
Adafruit Industries LLC
3,39 €
View More Details
Mfr Part # 3299
BLACK NYLON SCREW AND STAND-OFF
Adafruit Industries LLC
14,54 €
View More Details
Add all DigiKey Parts to Cart
Have questions or comments? Continue the conversation on TechForum, DigiKey's online community and technical resource.