# UFO Drone

## Overview

https://www.youtube.com/watch?v=wT_3D-bjBzM

In this project we’ll show you how we added NeoPixels to our drone to make it look like a it has a tractor beam.&nbsp;

This is really simple project just in time for Halloween or&nbsp;even lighting effects for a video.

All you’ll need to build this project is an Adafruit Trinket and a 24 NeoPixel ring.

We designed and 3D printed a custom mount to attach to the landing gear of a DJI Phantom 4.&nbsp;The Phantom 4 is able to power the trinket through the USB&nbsp;port on the side and the 3d printed clips holds all of the parts.

![](https://cdn-learn.adafruit.com/assets/assets/000/036/775/medium800thumb/led_pixels_hover2-loop.jpg?1477362015)

## Prerequisite Guides

We suggest walking through the following guides to get a better understanding of the components and Arduino IDE. We also have great tutorials on learning how to solder.

- [Collin's Lab: Soldering](../../../../collins-lab-soldering/video)
- [Adafruit's Uber NeoPixel Guide](../../../../adafruit-neopixel-uberguide)
- [Adafruit Trinket](../../../../introducing-trinket/downloads?view=all)

## Parts

All of the components used in this project are listed below and in the right hand sidebar.&nbsp;

- [Adafruit Trinket](https://www.adafruit.com/products/1500)
- [NeoPixel Ring - 24 x](https://www.adafruit.com/products/1586)
- [Filament for 3D Printers in Various Colors and Types](https://www.adafruit.com/products/2080)
- [USB OTG Host Cable - MicroB OTG male to A female](https://www.adafruit.com/products/1099)
- [USB cable - 6" A/MicroB](https://www.adafruit.com/products/898)

![](https://cdn-learn.adafruit.com/assets/assets/000/036/763/medium800/led_pixels_parts.jpg?1477351903)

## Tools & Supplies

You'll need some tools and supplies to complete this project, but feel free to improvise and use any materials you like.

- [3D Printer](https://www.adafruit.com/categories/245) & [Filament](https://www.adafruit.com/products/2080)
- [Soldering Iron](https://www.adafruit.com/categories/84) & Solder
- [Wire Strippers](https://www.adafruit.com/products/527) / [Cutters](https://www.adafruit.com/products/152)
- [Panavise Jr.](https://www.adafruit.com/products/151) / [Helping Third Hands](https://www.adafruit.com/products/291)
- USB Cable & [Wire](https://www.adafruit.com/categories/473)

# UFO Drone

## Circuit Diagram

![](https://cdn-learn.adafruit.com/assets/assets/000/036/789/medium800/led_pixels_ufo-circuit.jpg?1477418703)

Follow the diagram above to connect the NeoPixel Ring to the Trinket. You can measure the wire lengths by mounting the ring and Trinket to the 3d part and then cutting the required sizes for each pin.&nbsp;

To keep the wires nice and&nbsp;short, rotate the ring so the pins are close to the pins on the Trinket.

**GND** on the Ring connects to&nbsp;ground on the Trinket

**5v** on the Ring connects to USB on the Trinket

**DIN** on the Ring connects to pin #0 on the Trinket

# UFO Drone

## 3D Printing

## Download and 3D Print

The 3D printed parts can be downloaded from&nbsp;the links below.&nbsp;

[Download STLs on Pinshape](https://pinshape.com/items/27718-3d-printed-dji-phantom-4-neopixel-mount)
[Download STLs on Thingiverse](http://www.thingiverse.com/thing:1850790)
[Download STLs on YouMagine](https://www.youmagine.com/designs/dji-phantom-4-neopixel-mount)
![](https://cdn-learn.adafruit.com/assets/assets/000/036/762/medium800/led_pixels_3d-part.jpg?1477351709)

You can also edit the designs if you have a different drone model or if you just need parts references for the NeoPixel Ring or Trinket mouting holes.

[Edit Design](http://a360.co/2dR3suW)
## Materials & Slice Settings

This project with any material like PLA, ABS or Nylon. Reference&nbsp;the slice settings in the table below – We're using Simplify3D to slice the parts.

We use a .6mm to speed up print times, but a standard .4mm nozzle should work.

# UFO Drone

## Code

The LED animations are from the NeoPixel library but you can write your own or customize them in the Arduino Sketch.

## Getting Code Onto Trinket

In this portion of the guide, we'll get code uploaded to the **Adafruit Trinket** micro-controller. If you don't write / understand code, don't&nbsp;to worry! You don't need to be a programmer to be able to upload prewritten code :-)&nbsp;

We'll walk you through the whole process.&nbsp;

First, visit the Trinket tutorial page by clicking the button below. Follow the instructions to download & setup the Arduino IDE and install drivers.

[Getting started with Trinket!](../../../../introducing-trinket/)

Make sure you are able to get sketches compiled and uploaded, especially the blink example in the tutorial. Once you are comfortable with using the Trinket, you can continue!

## Install Adafruit NeoPixel Library

Next, we need to add support for NeoPixels.

Visit the Adafruit NeoPixel tutorial to install the NeoPixel library!

[Install NeoPixel Library](../../../../adafruit-neopixel-uberguide/arduino-library-installation)

## Uploading Code to Board

Now that we have the Adafruit boards & NeoPixel library installed, we can get our code ready to upload onto the board. Select all of the code listed below in the black box and copy it to your clip board. Then, in Arduino IDE, paste it in the sketch window (making sure to overwrite anything currently there). Next, goto the **Tools** menu \> **Board** and select **Adafruit**  **Trinket 8Mhz**. Now you can click on the " **check mark**" icon to verify the code. If it's all good, we can continue to upload the code to the board.

## Connect USB Data Cable to Trinket

**Be sure to use a micro USB cable that can transfer data - A USB cable that ONLY charges devices will simply not work.**

Plug it into the microUSB port on the Adafruit Trinket board and the USB port on your computer (try to avoid connecting to a USB hub). As soon as you plug it in, you'll see a red LED blink on the Adaruit Trinket - This let's you know the board is ready to except code. While the LED is blinking, click on the Upload button (It's a right arrow icon, next to the chekc mark). The Arduino IDE will notify you if the upload is successful and&nbsp;completed.

```
#include &lt;Adafruit_NeoPixel.h&gt;
#ifdef __AVR__
  #include &lt;avr/power.h&gt;
#endif

#define PIN 0

// Parameter 1 = number of pixels in strip
// Parameter 2 = Arduino pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
//   NEO_KHZ800  800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
//   NEO_KHZ400  400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
//   NEO_GRB     Pixels are wired for GRB bitstream (most NeoPixel products)
//   NEO_RGB     Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
//   NEO_RGBW    Pixels are wired for RGBW bitstream (NeoPixel RGBW products)
Adafruit_NeoPixel strip = Adafruit_NeoPixel(24, PIN, NEO_GRB + NEO_KHZ800);

// IMPORTANT: To reduce NeoPixel burnout risk, add 1000 uF capacitor across
// pixel power leads, add 300 - 500 Ohm resistor on first pixel's data input
// and minimize distance between Arduino and first pixel.  Avoid connecting
// on a live circuit...if you must, connect GND first.

void setup() {
  // This is for Trinket 5V 16MHz, you can remove these three lines if you are not using a Trinket
  #if defined (__AVR_ATtiny85__)
    if (F_CPU == 16000000) clock_prescale_set(clock_div_1);
  #endif
  // End of trinket special code


  strip.begin();
  strip.show(); // Initialize all pixels to 'off'
}

void loop() {
  // Some example procedures showing how to display to the pixels:
  colorWipe(strip.Color(255, 0, 0), 50); // Red
  colorWipe(strip.Color(0, 255, 0), 50); // Green
  colorWipe(strip.Color(0, 0, 255), 50); // Blue
//colorWipe(strip.Color(0, 0, 0, 255), 50); // White RGBW
  // Send a theater pixel chase in...
  theaterChase(strip.Color(127, 127, 127), 50); // White
  theaterChase(strip.Color(127, 0, 0), 50); // Red
  theaterChase(strip.Color(0, 0, 127), 50); // Blue

  rainbow(20);
  rainbowCycle(20);
  theaterChaseRainbow(50);
}

// Fill the dots one after the other with a color
void colorWipe(uint32_t c, uint8_t wait) {
  for(uint16_t i=0; i&lt;strip.numPixels(); i++) {
    strip.setPixelColor(i, c);
    strip.show();
    delay(wait);
  }
}

void rainbow(uint8_t wait) {
  uint16_t i, j;

  for(j=0; j&lt;256; j++) {
    for(i=0; i&lt;strip.numPixels(); i++) {
      strip.setPixelColor(i, Wheel((i+j) &amp; 255));
    }
    strip.show();
    delay(wait);
  }
}

// Slightly different, this makes the rainbow equally distributed throughout
void rainbowCycle(uint8_t wait) {
  uint16_t i, j;

  for(j=0; j&lt;256*5; j++) { // 5 cycles of all colors on wheel
    for(i=0; i&lt; strip.numPixels(); i++) {
      strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) &amp; 255));
    }
    strip.show();
    delay(wait);
  }
}

//Theatre-style crawling lights.
void theaterChase(uint32_t c, uint8_t wait) {
  for (int j=0; j&lt;10; j++) {  //do 10 cycles of chasing
    for (int q=0; q &lt; 3; q++) {
      for (uint16_t i=0; i &lt; strip.numPixels(); i=i+3) {
        strip.setPixelColor(i+q, c);    //turn every third pixel on
      }
      strip.show();

      delay(wait);

      for (uint16_t i=0; i &lt; strip.numPixels(); i=i+3) {
        strip.setPixelColor(i+q, 0);        //turn every third pixel off
      }
    }
  }
}

//Theatre-style crawling lights with rainbow effect
void theaterChaseRainbow(uint8_t wait) {
  for (int j=0; j &lt; 256; j++) {     // cycle all 256 colors in the wheel
    for (int q=0; q &lt; 3; q++) {
      for (uint16_t i=0; i &lt; strip.numPixels(); i=i+3) {
        strip.setPixelColor(i+q, Wheel( (i+j) % 255));    //turn every third pixel on
      }
      strip.show();

      delay(wait);

      for (uint16_t i=0; i &lt; strip.numPixels(); i=i+3) {
        strip.setPixelColor(i+q, 0);        //turn every third pixel off
      }
    }
  }
}

// Input a value 0 to 255 to get a color value.
// The colours are a transition r - g - b - back to r.
uint32_t Wheel(byte WheelPos) {
  WheelPos = 255 - WheelPos;
  if(WheelPos &lt; 85) {
    return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
  }
  if(WheelPos &lt; 170) {
    WheelPos -= 85;
    return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
  }
  WheelPos -= 170;
  return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
}
```

# UFO Drone

## Assemble

![](https://cdn-learn.adafruit.com/assets/assets/000/036/764/medium800/led_pixels_solder-ringB.jpg?1477352255)

## Set up Neopixel ring

To set up the LEDs we’ll measure, cut, tin and solder silicone wires to the power, ground and data on the neopixel ring.

![](https://cdn-learn.adafruit.com/assets/assets/000/036/766/medium800/led_pixels_trinket-mountB.jpg?1477353871)

## Mounting the Trinket

Postion the Trinket so the USB port&nbsp;faces towards the outside of the ring.

Next we can use 2.5mm screws to mount the trinket to the 3d printed clip. You can tap holes for screws&nbsp;first to make mouting easier.&nbsp;

![](https://cdn-learn.adafruit.com/assets/assets/000/036/771/medium800thumb/led_pixels_ring-mount.jpg?1477359915)

## Attaching NeoPixel Ring&nbsp;

The NeoPixel Ring snaps onto the 3d part&nbsp;with the LEDs facing outward. Carefully fit the wires through the slits on the ring mount and snap the ring onto the part. You can use tweezers to fit the wires through the slits.

![](https://cdn-learn.adafruit.com/assets/assets/000/036/765/medium800/led_pixels_solder-trinketB.jpg?1477352778)

## Solder Ring to Trinket&nbsp;

You may need to rotate the ring so that each pin is close to the pins on the Trinket.&nbsp;

Tin pins #0, ground and USB on the Trinket and then solder&nbsp;each connection from the ring. Use tweezers to&nbsp;hold wires while soldering.&nbsp;

![](https://cdn-learn.adafruit.com/assets/assets/000/036/767/medium800/led_pixels_circuit-completeB.jpg?1477353952)

![](https://cdn-learn.adafruit.com/assets/assets/000/036/772/medium800thumb/led_pixels_clip-mount-loop.jpg?1477360470)

## Attach the clip

To install, we simply press the clips on both ends to the landing gear. The tolerances are nice and tight, but you can still have the option to adjust the position by sliding it.

There’s just enough clearance for the camera but we made sure to position it away from the proximity sensors.

&nbsp;

![](https://cdn-learn.adafruit.com/assets/assets/000/036/773/medium800/led_pixels_usb-plug.jpg?1477360795)

## Power

We can power the whole circuit using the micro USB port on the side of the Phantom 4.

The NeoPixels light up immediately after turning the Phantom 4 on and actually doesn’t affect the flight time so it doesn’t draw that much power.

![](https://cdn-learn.adafruit.com/assets/assets/000/036/774/medium800thumb/led_pixels_hover-loop.jpg?1477361205)

## Flying

The whole assembly is nicely contained and easy to carry around and&nbsp;we noticed the same amount of flight time, about 18 minutes.

The ring will get in the way of the camera view when you look down, but it’s out of the way otherwise!

## &nbsp;

## Lighting effects

To get the cool&nbsp;light beam effects it's best to fly when it's foggy. We&nbsp;used a fog machine machine when shooting the video, but if you shooting on location you could use [atmosphere aerosol](http://www.atmosphereaerosol.com/) to create light rays.&nbsp;


## Featured Products

### NeoPixel Ring - 24 x 5050 RGB LED with Integrated Drivers

[NeoPixel Ring - 24 x 5050 RGB LED with Integrated Drivers](https://www.adafruit.com/product/1586)
Round and round and round they go! 24 ultra bright smart LED NeoPixels are arranged in a circle with 2.6" (66mm) outer diameter. The rings are 'chainable' - connect the output pin of one to the input pin of another. Use only one microcontroller pin to control as many as you can...

In Stock
[Buy Now](https://www.adafruit.com/product/1586)
[Related Guides to the Product](https://learn.adafruit.com/products/1586/guides)
### Adafruit Trinket - Mini Microcontroller - 5V Logic

[Adafruit Trinket - Mini Microcontroller - 5V Logic](https://www.adafruit.com/product/1501)
 **Deprecation Warning: The Trinket bit-bang USB technique it uses doesn't work as well as it did in 2014, many modern computers won't work well. So while we still carry the Trinket so that people can maintain some older projects, we no longer recommend it.** <a...></a...>

In Stock
[Buy Now](https://www.adafruit.com/product/1501)
[Related Guides to the Product](https://learn.adafruit.com/products/1501/guides)
### PLA Filament for 3D Printers - 1.75mm Natural Translucent - 1KG

[PLA Filament for 3D Printers - 1.75mm Natural Translucent - 1KG](https://www.adafruit.com/product/2451)
Having a 3D printer without filament is sort of like having a regular printer without paper or ink. &nbsp;And while a lot of printers come with some filament there's a good chance you've been printing up a storm and need something new. &nbsp;That's why we've started carrying a...

No Longer Stocked
[Buy Now](https://www.adafruit.com/product/2451)
[Related Guides to the Product](https://learn.adafruit.com/products/2451/guides)
### USB OTG Host Cable - MicroB OTG male to A female

[USB OTG Host Cable - MicroB OTG male to A female](https://www.adafruit.com/product/1099)
This cable looks like a USB micro cable but it isn't! Instead of a USB A Plug, it has a USB A Socket on the end. This cable is designed for use with OTG (On the Go) host devices (like the Arduino Due or many tablets) so you can connect a mouse, keyboard, or any other USB device. You'll...

In Stock
[Buy Now](https://www.adafruit.com/product/1099)
[Related Guides to the Product](https://learn.adafruit.com/products/1099/guides)
### USB cable - 6" A/MicroB

[USB cable - 6" A/MicroB](https://www.adafruit.com/product/898)
This here is your standard A-microB USB cable, for USB 1.1 or 2.0. Perfect for connecting a PC to your NETduino, Arduino Leonardo, Raspberry Pi (among other things).  
  
Approximately 6.5" long from end to end, its a little more compact than our classic 3' long cable  
<br...></br...>

In Stock
[Buy Now](https://www.adafruit.com/product/898)
[Related Guides to the Product](https://learn.adafruit.com/products/898/guides)
### Ultimaker 3 - 3D Printer

[Ultimaker 3 - 3D Printer](https://www.adafruit.com/product/3300)
The **Ultimaker 3** &nbsp;is one of our favorite 3D printers on the market. It's a well-built open-source compact machine with an excellent UX.&nbsp;Every inch of the Ultimaker 3&nbsp;is designed to create the most effortless and reliable 3D printing experience ever!&nbsp;<a...></a...>

No Longer Stocked
[Buy Now](https://www.adafruit.com/product/3300)
[Related Guides to the Product](https://learn.adafruit.com/products/3300/guides)

## Related Guides

- [Kaleidoscope Eyes (Trinket-Powered NeoPixel LED Ring Goggles)](https://learn.adafruit.com/kaleidoscope-eyes-neopixel-led-goggles-trinket-gemma.md)
- [Trinket (& Gemma) Servo Control](https://learn.adafruit.com/trinket-gemma-servo-control.md)
- [NeoPixel Arcade Buttons](https://learn.adafruit.com/neopixel-arcade-button.md)
- [Trinket Powered Analog Meter Clock](https://learn.adafruit.com/trinket-powered-analog-meter-clock.md)
- [Multi-tasking the Arduino - Part 3](https://learn.adafruit.com/multi-tasking-the-arduino-part-3.md)
- [Neopixel Crystal Chandelier with CircuitPython Animations and Speed Control](https://learn.adafruit.com/neopixel-crystal-chandelier-with-circuitpython-animations-and-speed-control.md)
- [Your Pulse Displayed with NeoPixels](https://learn.adafruit.com/pulse-sensor-displayed-with-neopixels.md)
- [Trinket “Question Block” Sound Jewelry](https://learn.adafruit.com/trinket-question-block-sound-jewelry.md)
- [3D Printed Daft Punk Helmet with Bluetooth ](https://learn.adafruit.com/3d-printed-daft-punk-helmet-with-bluetooth.md)
- [LED Trinket Tree Topper](https://learn.adafruit.com/neopixel-led-trinket-tree-topper.md)
- [Festive Feather Holiday Lights](https://learn.adafruit.com/festive-feather-holiday-lights.md)
- [Let’s Put LEDs in Things!](https://learn.adafruit.com/lets-put-leds-in-things.md)
- [Mario Magic Wand](https://learn.adafruit.com/mario-magic-wand.md)
- [Mystery Box: Shutterglass Chamber](https://learn.adafruit.com/shutterglass-chamber.md)
- [Trinket / Gemma IR Control](https://learn.adafruit.com/trinket-gemma-ir-remote-control.md)
