# Remote Control Candy Dispenser Ghost

## Overview

https://youtu.be/SwCxFk3fIb4

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.gif](https://cdn-learn.adafruit.com/assets/assets/000/096/318/medium640thumb/3d_printing_hero-drop.jpg?1603566017)

![3d_printing_hero-claw-loop.gif](https://cdn-learn.adafruit.com/assets/assets/000/096/319/medium640thumb/3d_printing_hero-claw-loop.jpg?1603566055)

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-loop3.gif](https://cdn-learn.adafruit.com/assets/assets/000/096/320/medium640thumb/3d_printing_ghost-drop-loop3.jpg?1603566153)

![3d_printing_assembled-claw-loop.gif](https://cdn-learn.adafruit.com/assets/assets/000/096/321/medium640thumb/3d_printing_assembled-claw-loop.jpg?1603566226)

![](https://cdn-learn.adafruit.com/assets/assets/000/096/322/medium800thumb/3d_printing_ghost-drop-loop2.jpg?1603566281)

## Parts
### Circuit Playground Bluefruit - Bluetooth® Low Energy

[Circuit Playground Bluefruit - Bluetooth® Low Energy](https://www.adafruit.com/product/4333)
 **Circuit Playground Bluefruit** is our third board in the Circuit Playground series, another step towards a perfect introduction to electronics and programming. We've taken the popular Circuit Playground Express and made it even better! Now the main chip is an nRF52840...

Out of Stock
[Buy Now](https://www.adafruit.com/product/4333)
[Related Guides to the Product](https://learn.adafruit.com/products/4333/guides)
![shot of a Black woman's neon-green manicured hand holding up a Circuit Playground Bluefruit glowing rainbow LEDs.](https://cdn-shop.adafruit.com/640x480/4333-11.jpg)

### Micro Servo - MG90D High Torque Metal Gear

[Micro Servo - MG90D High Torque Metal Gear](https://www.adafruit.com/product/1143)
Add more power to your robot with this metal-geared MG90D&nbsp;servo. The tiny little servo can rotate approximately 90 degrees (45 in each direction) and works just like the standard kinds you're used to but _smaller_. You can use any servo code, hardware, or library to control...

In Stock
[Buy Now](https://www.adafruit.com/product/1143)
[Related Guides to the Product](https://learn.adafruit.com/products/1143/guides)
![High Torque Metal Gear Micro Servo  with three pin cable](https://cdn-shop.adafruit.com/640x480/1143-08.jpg)

### Lithium Ion Polymer Battery - 3.7v 500mAh

[Lithium Ion Polymer Battery - 3.7v 500mAh](https://www.adafruit.com/product/1578)
Lithium-ion polymer (also known as 'lipo' or 'lipoly') batteries are thin, light, and powerful. The output ranges from 4.2V when completely charged to 3.7V. This battery has a capacity of 500mAh for a total of about 1.9 Wh. If you need a larger (or smaller!) battery, <a...></a...>

In Stock
[Buy Now](https://www.adafruit.com/product/1578)
[Related Guides to the Product](https://learn.adafruit.com/products/1578/guides)
![Angled shot of a Lithium Ion Polymer Battery 3.7V 500mAh with JST-PH connector.](https://cdn-shop.adafruit.com/640x480/1578-03.jpg)

### Black Nylon Machine Screw and Stand-off Set – M3 Thread

[Black Nylon Machine Screw and Stand-off Set – M3 Thread](https://www.adafruit.com/product/4685)
Totaling **420 pieces** , this **M3 Screw Set** &nbsp;is a must-have for your workstation.&nbsp;You'll have enough screws, nuts, and hex standoffs to fuel your maker tendencies&nbsp;for days on end! M3 size screws fit a number of&nbsp;Adafruit breakout/dev board...

In Stock
[Buy Now](https://www.adafruit.com/product/4685)
[Related Guides to the Product](https://learn.adafruit.com/products/4685/guides)
![Opened box showing many nylon screws](https://cdn-shop.adafruit.com/640x480/4685-01.jpg)

### Fully Reversible Pink/Purple USB A to micro B Cable - 1m long

[Fully Reversible Pink/Purple USB A to micro B Cable - 1m long](https://www.adafruit.com/product/4111)
This cable is not only super-fashionable, with a woven pink and purple Blinka-like pattern, it's also fully reversible! That's right, you will save _seconds_ a day by not having to flip the cable around.

First let's talk about the cover and over-molding. We got these...

In Stock
[Buy Now](https://www.adafruit.com/product/4111)
[Related Guides to the Product](https://learn.adafruit.com/products/4111/guides)
![Fully Reversible Pink/Purple USB A to micro B Cable](https://cdn-shop.adafruit.com/640x480/4111-02.jpg)

## &nbsp;

&nbsp;

![3d_printing_parts.jpg](https://cdn-learn.adafruit.com/assets/assets/000/096/349/medium640/3d_printing_parts.jpg?1603570966)

![3d_printing_screws.jpg](https://cdn-learn.adafruit.com/assets/assets/000/096/350/medium640/3d_printing_screws.jpg?1603571034)

### Part: Small Flying Ghost
quantity: 1
Small Flying Ghost Decoration
[Small Flying Ghost](https://www.spirithalloween.com/product/small-flying-ghost-decorations/55717.uts)

### Part: M3x10mm Screw
quantity: 4
M3x10mm Screw
[M3x10mm Screw](https://www.adafruit.com/product/4685)

### Part: M3x6mm Screw + Nut
quantity: 1
M3x6mm Screw
[M3x6mm Screw + Nut](https://www.adafruit.com/product/4685)

### Part: M2.5 x 6mm Screw
quantity: 2
M2.5 x 6mm Screw
[M2.5 x 6mm Screw](https://www.adafruit.com/product/3299)

### Part: 1.25mm Pitch 3-pin Cable Matching Pair
quantity: 1
1.25mm Pitch 3-pin Cable Matching Pair
[1.25mm Pitch 3-pin Cable Matching Pair](https://www.adafruit.com/product/4721)

# Remote Control Candy Dispenser Ghost

## Circuit Diagram

The diagram below provides a visual reference for wiring of the components. This diagram was created using the software package&nbsp;[Fritzing](http://fritzing.org/download/).

## 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&nbsp;[GitHub - Adafruit Fritzing Parts](https://github.com/adafruit/Fritzing-Library/tree/master/parts).

![](https://cdn-learn.adafruit.com/assets/assets/000/096/323/medium800/3d_printing_CPB-Claw.jpg?1603566338)

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

- Red goes from&nbsp; **VOUT** &nbsp;to servo red voltage wire
- Black goes from&nbsp; **GND** &nbsp;to servo brown ground wire
- Yellow goes from&nbsp; **A3** &nbsp;to servo yellow signal wire

# Remote Control Candy Dispenser Ghost

## 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](https://circuitpython.org/board/circuitplayground_bluefruit/)
 **Click the link above and download the latest UF2 file**

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

![adafruit_products_CPB_Download_UF2.png](https://cdn-learn.adafruit.com/assets/assets/000/080/530/medium640/adafruit_products_CPB_Download_UF2.png?1567715178)

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!)

![adafruit_products_CPB_Front_Reset_Button_Arrow.jpg](https://cdn-learn.adafruit.com/assets/assets/000/080/532/medium640/adafruit_products_CPB_Front_Reset_Button_Arrow.jpg?1567715535)

You will see a new disk drive appear called **CPLAYBTBOOT**.

&nbsp;

&nbsp;

&nbsp;

Drag the **adafruit\_circuitpython\_etc.uf2** file to **CPLAYBTBOOT.**

![adafruit_products_CPB_CPLAYBTBOOT.png](https://cdn-learn.adafruit.com/assets/assets/000/080/533/medium640/adafruit_products_CPB_CPLAYBTBOOT.png?1567715858)

![adafruit_products_CBP_drag_UF2.png](https://cdn-learn.adafruit.com/assets/assets/000/080/534/medium640/adafruit_products_CBP_drag_UF2.png?1567715871)

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! :)

![adafruit_products_CBP_CIRCUITPY.png](https://cdn-learn.adafruit.com/assets/assets/000/080/535/medium640/adafruit_products_CBP_CIRCUITPY.png?1567716034)

# Remote Control Candy Dispenser Ghost

## Code

![](https://cdn-learn.adafruit.com/assets/assets/000/096/415/medium800/3d_printing_usb-circuitpy-drive.jpg?1603733771)

Once your CPB is set up with CircuitPython, you'll also need to add some libraries. [Follow this page](https://learn.adafruit.com/adafruit-circuit-playground-bluefruit/circuitpython-libraries) 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](https://learn.adafruit.com/welcome-to-circuitpython/installing-mu-editor).

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

![3d_printing_code-wide-loop.gif](https://cdn-learn.adafruit.com/assets/assets/000/096/324/medium640thumb/3d_printing_code-wide-loop.jpg?1603566361)

## Code.py

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

https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/main/BLE_Candy_Claw/code.py

## 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.gif](https://cdn-learn.adafruit.com/assets/assets/000/096/325/medium640thumb/3d_printing_app-wide-loop.jpg?1603566403)

[Download BLE Connect App iOS](https://itunes.apple.com/us/app/adafruit-bluefruit-le-connect/id830125974?mt=8)
[Download BLE Connect App for Android](https://play.google.com/store/apps/details?id=com.adafruit.bluefruit.le.connect)
## 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**.&nbsp;

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

# Remote Control Candy Dispenser Ghost

## 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

![3d_printing_3d-parts.jpg](https://cdn-learn.adafruit.com/assets/assets/000/096/326/medium640/3d_printing_3d-parts.jpg?1603567578)

[Edit BLE Claw](https://a360.co/3jojQBH)
[Download BLE Claw STLs](https://www.thingiverse.com/thing:4634720)
## 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

![3d_printing_slice.gif](https://cdn-learn.adafruit.com/assets/assets/000/096/327/medium640thumb/3d_printing_slice.jpg?1603568144)

# Remote Control Candy Dispenser Ghost

## Assembly

## CPB wires

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

&nbsp;

## Servo Wires

Shorten the cables on the servo to keep the circuit tidy.  
Use heat shrink to insulate the connections.&nbsp;

![3d_printing_cpb-wires-soldered.jpg](https://cdn-learn.adafruit.com/assets/assets/000/096/328/medium640/3d_printing_cpb-wires-soldered.jpg?1603567968)

![3d_printing_servo-wires.jpg](https://cdn-learn.adafruit.com/assets/assets/000/096/329/medium640/3d_printing_servo-wires.jpg?1603568216)

## 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.

## &nbsp;

## Second Arm

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

&nbsp;

&nbsp;

![3d_printing_servo-nut.jpg](https://cdn-learn.adafruit.com/assets/assets/000/096/330/medium640/3d_printing_servo-nut.jpg?1603568154)

![3d_printing_servo-claw.jpg](https://cdn-learn.adafruit.com/assets/assets/000/096/333/medium640/3d_printing_servo-claw.jpg?1603568361)

![3d_printing_servo-claw-horn.jpg](https://cdn-learn.adafruit.com/assets/assets/000/096/334/medium640/3d_printing_servo-claw-horn.jpg?1603569208)

![3d_printing_servo-claw2.jpg](https://cdn-learn.adafruit.com/assets/assets/000/096/335/medium640/3d_printing_servo-claw2.jpg?1603569248)

## 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.

![3d_printing_servo-lid-attch.jpg](https://cdn-learn.adafruit.com/assets/assets/000/096/336/medium640/3d_printing_servo-lid-attch.jpg?1603569423)

## Case&nbsp;

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.

![3d_printing_case-lipo.jpg](https://cdn-learn.adafruit.com/assets/assets/000/096/337/medium640/3d_printing_case-lipo.jpg?1603569448)

![3d_printing_case-cpb-wires-thread.jpg](https://cdn-learn.adafruit.com/assets/assets/000/096/338/medium640/3d_printing_case-cpb-wires-thread.jpg?1603569473)

## Case Screws

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

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

&nbsp;

## Attach Case

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

![3d_printing_case-wires-screws.jpg](https://cdn-learn.adafruit.com/assets/assets/000/096/339/medium640/3d_printing_case-wires-screws.jpg?1603569507)

![3d_printing_foam-tape-lid-.jpg](https://cdn-learn.adafruit.com/assets/assets/000/096/340/medium640/3d_printing_foam-tape-lid-.jpg?1603569604)

## Complete!

&nbsp;

![3d_printing_loop-claw-heroc.gif](https://cdn-learn.adafruit.com/assets/assets/000/096/347/medium640thumb/3d_printing_loop-claw-heroc.jpg?1603570693)

![3d_printing_ghost-drop-loop.gif](https://cdn-learn.adafruit.com/assets/assets/000/096/348/medium640thumb/3d_printing_ghost-drop-loop.jpg?1603570705)


## Featured Products

### Circuit Playground Bluefruit - Bluetooth® Low Energy

[Circuit Playground Bluefruit - Bluetooth® Low Energy](https://www.adafruit.com/product/4333)
 **Circuit Playground Bluefruit** is our third board in the Circuit Playground series, another step towards a perfect introduction to electronics and programming. We've taken the popular Circuit Playground Express and made it even better! Now the main chip is an nRF52840...

Out of Stock
[Buy Now](https://www.adafruit.com/product/4333)
[Related Guides to the Product](https://learn.adafruit.com/products/4333/guides)
### Micro Servo - MG90D High Torque Metal Gear

[Micro Servo - MG90D High Torque Metal Gear](https://www.adafruit.com/product/1143)
Add more power to your robot with this metal-geared MG90D&nbsp;servo. The tiny little servo can rotate approximately 90 degrees (45 in each direction) and works just like the standard kinds you're used to but _smaller_. You can use any servo code, hardware, or library to control...

In Stock
[Buy Now](https://www.adafruit.com/product/1143)
[Related Guides to the Product](https://learn.adafruit.com/products/1143/guides)
### 1.25mm Pitch 3-pin Cable Matching Pair - 40cm long

[1.25mm Pitch 3-pin Cable Matching Pair - 40cm long](https://www.adafruit.com/product/4721)
When 0.1" is too big, and JST PH's too chunky, these ultra-slim 1.25mm connectors are a reliable alternative. These are only 1.25mm pitch, but have a nice clicky connection.

These cables are&nbsp;nice and long, 40cm in fact. They've&nbsp;got both small form factor and are a...

In Stock
[Buy Now](https://www.adafruit.com/product/4721)
[Related Guides to the Product](https://learn.adafruit.com/products/4721/guides)
### Lithium Ion Polymer Battery - 3.7v 500mAh

[Lithium Ion Polymer Battery - 3.7v 500mAh](https://www.adafruit.com/product/1578)
Lithium-ion polymer (also known as 'lipo' or 'lipoly') batteries are thin, light, and powerful. The output ranges from 4.2V when completely charged to 3.7V. This battery has a capacity of 500mAh for a total of about 1.9 Wh. If you need a larger (or smaller!) battery, <a...></a...>

In Stock
[Buy Now](https://www.adafruit.com/product/1578)
[Related Guides to the Product](https://learn.adafruit.com/products/1578/guides)
### Black Nylon Machine Screw and Stand-off Set – M3 Thread

[Black Nylon Machine Screw and Stand-off Set – M3 Thread](https://www.adafruit.com/product/4685)
Totaling **420 pieces** , this **M3 Screw Set** &nbsp;is a must-have for your workstation.&nbsp;You'll have enough screws, nuts, and hex standoffs to fuel your maker tendencies&nbsp;for days on end! M3 size screws fit a number of&nbsp;Adafruit breakout/dev board...

In Stock
[Buy Now](https://www.adafruit.com/product/4685)
[Related Guides to the Product](https://learn.adafruit.com/products/4685/guides)
### Black Nylon Machine Screw and Stand-off Set – M2.5 Thread

[Black Nylon Machine Screw and Stand-off Set – M2.5 Thread](https://www.adafruit.com/product/3299)
Totaling 380 pieces, this **M2.5 Screw Set** &nbsp;is a must-have for your workstation.&nbsp;You'll have enough screws, nuts, and hex standoffs to fuel your maker tendencies&nbsp;for days on end! M2.5 size screws fit almost all of the Adafruit breakout/dev board mounting holes...

In Stock
[Buy Now](https://www.adafruit.com/product/3299)
[Related Guides to the Product](https://learn.adafruit.com/products/3299/guides)
### Fully Reversible Pink/Purple USB A to micro B Cable - 1m long

[Fully Reversible Pink/Purple USB A to micro B Cable - 1m long](https://www.adafruit.com/product/4111)
This cable is not only super-fashionable, with a woven pink and purple Blinka-like pattern, it's also fully reversible! That's right, you will save _seconds_ a day by not having to flip the cable around.

First let's talk about the cover and over-molding. We got these...

In Stock
[Buy Now](https://www.adafruit.com/product/4111)
[Related Guides to the Product](https://learn.adafruit.com/products/4111/guides)

## Related Guides

- [Adafruit Circuit Playground Bluefruit](https://learn.adafruit.com/adafruit-circuit-playground-bluefruit.md)
- [PyLeap Blink Animation](https://learn.adafruit.com/pyleap-device-enabled-blinky.md)
- [Raspberry Pi Pico and LED Arcade Button MIDI Controller](https://learn.adafruit.com/raspberry-pi-pico-led-arcade-button-midi-controller-fighter.md)
- [FunHouse IoT Fume Extractor and Air Quality Sensor](https://learn.adafruit.com/funhouse-fume-extractor-iot-air-quality-sensor.md)
- [Now Playing: Bluetooth Apple Media Service Display](https://learn.adafruit.com/now-playing-bluetooth-apple-media-service-display.md)
- [Remote Effects Trigger Box](https://learn.adafruit.com/remote-effects-trigger.md)
- [HalloWing Magic 9 Ball](https://learn.adafruit.com/hallowing-magic-9-ball.md)
- [CircuitPython OLED Watch Clock](https://learn.adafruit.com/circuitpython-oled-watch.md)
- [Adafruit Swirly Aluminum Mounting Grid for 0.1" Spaced PCBs](https://learn.adafruit.com/swirly-grid.md)
- [Circuit Playground Bluefruit Pumpkin with Lights and Sounds ](https://learn.adafruit.com/pumpkin-with-circuit-playground-bluefruit.md)
- [Computer Space Mini Arcade](https://learn.adafruit.com/computer-space-mini-arcade.md)
- [Automatic Naughty Cat Detector using Lobe](https://learn.adafruit.com/naughty-cat-detector-using-microsoft-lobe.md)
- [Multi-tasking with CircuitPython](https://learn.adafruit.com/multi-tasking-with-circuitpython.md)
- [Solderless Robot Toy Xylophone](https://learn.adafruit.com/solderless-robot-toy-xylophone.md)
- [Numpad 4000 Mechanical Keyswitch Data Entry Device](https://learn.adafruit.com/numpad-4000-mechanical-keyswitch-data-entry-device.md)
- [NeoKey Emoji Keyboard](https://learn.adafruit.com/neokey-emoji-keyboard.md)
