# Quadcopter Spray Can Mod

## Overview

![](https://cdn-learn.adafruit.com/assets/assets/000/025/803/medium800/hacks_drone-spray-bot.jpg?1433452623)

This guide follows an attempt to make a spray painting quadcopter for indoor drone painting.

It is a series of experiments and observations, not quite a perfect step-by-step tutorial! =D

Use this guide on your own property only! We do not endorse the use of this technology for any illegal painting.

This guide was developed with support from [NEWINC](http://www.newinc.org/), [Deep Lab](http://www.deeplab.net/),&nbsp;and [3D Robotics](http://3drobotics.com/), and through collaboration with [Dan Moore](http://makeitdoathing.com/)&nbsp;and KATSU.

https://youtu.be/aJPCvV_xGFc

# Quadcopter Spray Can Mod

## Materials & Tools

![](https://cdn-learn.adafruit.com/assets/assets/000/025/800/medium800/hacks_dan-holding-spray-bot.jpg?1433451787)

This project has many parts and optional components.

For the sprayer device:

- [Can Gun](https://www.amazon.com/gp/product/B00UGHLSDU/ref=oh_aui_detailpage_o01_s00?ie=UTF8&psc=1)&nbsp;or&nbsp;[Spray Extender](http://www.amazon.com/gp/product/B0014HBQLA/ref=oh_aui_detailpage_o01_s00?ie=UTF8&psc=1)
- [Micro servo](http://www.adafruit.com/product/169)&nbsp;or&nbsp;[high-torque micro servo](http://www.adafruit.com/product/1143)
- Paper clip or other small piece of wire
- Rotary tool for drilling mounting holes
- Zipties and/or E6000 adhesive

For the plug-and-play power circuit:

- Piece of [Perma-Proto](http://www.adafruit.com/product/589)&nbsp;or other perfboard
- [5V regulator](http://www.adafruit.com/product/2164)&nbsp;or&nbsp;[UBEC Step-Down (Buck) Converter](http://www.adafruit.com/product/1385)
- [Premium jumper wires](http://www.adafruit.com/product/760)
- Header pins
- Velcro tape
- Soldering station and supplies

General quadcopter stuff:

- [3D printed prop guards](http://www.thingiverse.com/thing:367230)&nbsp;(now updated for IRIS+)
- extra propellers
- spray paint with straw from cleaning spray bottle
- stiff wire for mounting sprayer - we found that tomato cages work great

# Quadcopter Spray Can Mod

## Sprayer device

![](https://cdn-learn.adafruit.com/assets/assets/000/025/303/medium800/hacks_can_gun.jpg?1431100160)

This sprayer worked well for us but there are others available online or in your local hardware store that will work just as well! Open it up to reveal the mechanism inside...

![](https://cdn-learn.adafruit.com/assets/assets/000/025/305/medium800/hacks_can_gun-drying-glue.jpg?1431100232)

Test fit your micro servo in a location where the movement can pull the can trigger. Affix with E6000 glue or epoxy and allow to dry (quadcopter foot being used in above photo as a spacer only while the glue dries).

![](https://cdn-learn.adafruit.com/assets/assets/000/025/314/medium800/hacks_drill-holes-2.jpg?1431100879)

Drill a small hole in the trigger for affixing a wire later.

Cut the red trigger mechanism&nbsp;so it fits around the motor and doesn't intersect.

![hacks_drone-spray-cut-red-part.jpg](https://cdn-learn.adafruit.com/assets/assets/000/025/316/medium640/hacks_drone-spray-cut-red-part.jpg?1431101119)

![hacks_drone-spray-red-part-fits.jpg](https://cdn-learn.adafruit.com/assets/assets/000/025/317/medium640/hacks_drone-spray-red-part-fits.jpg?1431101156)

![](https://cdn-learn.adafruit.com/assets/assets/000/025/318/medium800/hacks_drone-spray-can-gun-servo-wire.jpg?1431101264)

Attach a wire to the horn of the motor and run it through the hole in the trigger. It's also useful to route out a bit of clearance in the handle itself for the wire to move.

![](https://cdn-learn.adafruit.com/assets/assets/000/025/319/medium800/hacks_drone-spray-can-gun-servo-closed-in.jpg?1431101378)

Route the servo wire out the top of the can gun and leave slack on the trigger wire for calibrating later.

![](https://cdn-learn.adafruit.com/assets/assets/000/025/320/medium800/hacks_drone-spray-can-gun-two.jpg?1431101475)

When prototyping, it's always helpful to have two of each part in case one breaks or needs troubleshooting! The can gun on the right suffered a small break while trimming the red trigger, which was fixed with pieces of a chopstick and copious glue. Learn from our mistake and only trim a small amount from the red trigger mechanism. =]

![](https://cdn-learn.adafruit.com/assets/assets/000/025/313/medium800/hacks_othertypeofsprayer.jpg?1431100795)

We also had success with [this type of spray trigger](https://www.amazon.com/gp/product/B0014HBQLA/ref=oh_aui_detailpage_o04_s00?ie=UTF8&psc=1), which was designed to attach to the end of a painting extension pole for spraying wasps' nests, etc. This type did not require any drilling, as the motor sits nicely at the pole junction, held in place with zip ties.

![](https://cdn-learn.adafruit.com/assets/assets/000/025/315/medium800/hacks_drill-holes-1.jpg?1431100888)

Holes do need to be drilled for mounting to the quadcopter, however. =]

![](https://cdn-learn.adafruit.com/assets/assets/000/025/805/medium800/hacks_drone-spray-mount.jpg?1433454119)

To mount to IRIS+, we used a tomato cage (available at most big box home/garden stores), cut down to size. The round shape lets it fit against the bot's arms and attach with zip ties, and the three straight supports come down and stick into holes on the plastic sprayer.

# Quadcopter Spray Can Mod

## Power/servo circuit

![](https://cdn-learn.adafruit.com/assets/assets/000/025/300/medium800/hacks_5v-regulator_circuit.jpg?1431099906)

On a small piece of perfboard, solder a 5V regulator. Attach three wires with female headers to the perfboard: one to the regulator input (far left pin), one to the regulator ground (center pin), and one to a free row on the perfboard (servo control).

Solder three header pins to the perfboard in a row: to the voltage regulator ground, output, and the servo control wire.

![](https://cdn-learn.adafruit.com/assets/assets/000/025/301/medium800/hacks_UBEC-circuit.jpg?1431100087)

If you want to control more than just a servo, use a buck converter! It can deliver more current without heating up. It is wired similarly to the voltage regulator where the 12V battery source and ground hooks up to the input, and the header pins wire up to the output + and -, as well as the servo control as above.

# Quadcopter Spray Can Mod

## Control servo with IRIS+

![](https://cdn-learn.adafruit.com/assets/assets/000/025/307/medium800/hacks_attach-circuit-to-iris.jpg?1431100312)

Use Velcro tape to affix the PCB to the underside of IRIS+.

Connect the voltage regulator input wire to IRIS+'s red power wire, and likewise connect the ground wire to the black IRIS+ ground wire.

Connect the servo signal wire to the white wire on IRIS+ (shown above is original IRIS with different colored wires). The black wire remains not connected.

![](https://cdn-learn.adafruit.com/assets/assets/000/025/311/medium800/hacks_attach-sprayer-motor-to-power-circuit.jpg?1431100709)

Connect the servo to the header pins on the circuit, being sure to connect it in the correct orientation-- the brown wire is ground and should align with the voltage regulator center pin (ground), the red wire is positive and should align with the voltage regulator output, and the yellow wire should align with the servo signal coming from IRIS+.

![](https://cdn-learn.adafruit.com/assets/assets/000/025/321/medium800/hacks_drone-spray-testing-with-iris.jpg?1431101692)

We'll configure IRIS+ to activate the servo as if it were one of the servos in a gimbal.&nbsp;

![](https://cdn-learn.adafruit.com/assets/assets/000/025/802/medium800thumb/hacks_drone-spray-channel-6.jpg?1448318195)

At first we triggered the servo with&nbsp;channel 6, the knob on the IRIS+ controller as shown above. On IRIS classic, this "just worked" when the servo control wire was plugged into the orange&nbsp;gimbal control wire because the knob is already configured to adjust the angle of a&nbsp;camera this way. This approach didn't work out of the box on IRIS+, however, and requires adjusting the parameters to link up the control channel to the gimbal control.

Another option is to link the imaginary gimbal's 'camera trigger' servo to channel 7 (the switch to the left of the knob on the controller). The system expects this servo to press for a configurable length of time, then release.

Either trigger mode might be preferable, depending on whether you want long stretches or short bursts of spray! Below is a parameter file you can load into your bot for the camera shutter option:

[paramter_iris_shutter.param.zip](https://learn.adafruit.com/system/assets/assets/000/028/670/original/paramter_iris_shutter.param.zip?1448150388)
Click the "LOAD" button on the right in your&nbsp;mission planning software, and select your recently downloaded param file to load.

![](https://cdn-learn.adafruit.com/assets/assets/000/025/817/medium800/hacks_Params_CAM.png?1433522987)

If you want to edit your own params, &nbsp;here's the important stuff! To use the channel 7 switch, set CH7\_OPT to 9:

![](https://cdn-learn.adafruit.com/assets/assets/000/025/814/medium800/hacks_CH7_OPT.png?1433522399)

To adjust the parameters of the servo control, set the RC7 parameters to the min/max and trim values of the servo:

![](https://cdn-learn.adafruit.com/assets/assets/000/025/815/medium800/hacks_RC7.png?1433522533)

Adjust your CAM\_\* parameters for spray duration, etc.:

![](https://cdn-learn.adafruit.com/assets/assets/000/025/816/medium800/hacks_SHUTTER_SETTINGS.png?1433522612)

# Quadcopter Spray Can Mod

## Settings for indoor flight

We followed the [ArduPilot tutorial on indoor flying](http://copter.ardupilot.com/wiki/common-use-cases-and-applications/indoor-flying/), so be sure to read through it thoroughly. We've created a settings profile you can load onto your copter but you should also be familiar with these basic ideas:

- many auto modes use GPS, and GPS doesn't work inside. GPS must be disabled and no auto modes can't be used.
- Adding a downward-facing sonar sensor can help make an indoor altitude hold mode

# Quadcopter Spray Can Mod

## Sonar sensor cables

The Pixhawk can receive&nbsp;info from two analog sonar sensors, which you can use to aid in an indoor "altitude hold" mode or for checking distance from a wall. Check out [the ArduPilot page on wiring and configuring sonar sensors](http://copter.ardupilot.com/wiki/common-optional-hardware/common-rangefinder-landingpage/common-rangefinder-maxbotix-analog/)&nbsp;to the Pixhawk and Mission Planner.

These sensors are sensitive to interference caused by the quadcopter's motors. To cut down on interference, a special cable must be made! In addition to one of the MaxBotix sensors suggested in the ArduPilot guide, you will need:

- shielded cable with at least three wires (recycled USB cable works)
- [100uF capacitor](https://www.adafruit.com/product/2193)
- 10 ohm resistor
- [heat shrink tubing](https://www.adafruit.com/product/1649)
- [5-position connector](https://store.3drobotics.com/products/df13-5-position-connector-10-cm-1?taxon_id=34)&nbsp;for Pixhawk

![](https://cdn-learn.adafruit.com/assets/assets/000/025/692/medium800/hacks_drone-spray-sonar-parts.jpg?1432837029)

![](https://cdn-learn.adafruit.com/assets/assets/000/025/801/medium800/hacks_drone-spray-sonar-wire-tinned.jpg?1433452139)

Strip and tin the three wires, joining the shielding to the black ground wire and attaching the resistor at the end of the red power lead. Slide a small piece of heat shrink over the resistor and its wire connection.

Insert black to ground, the power-line resistor to V+, and the white signal wire to the sensor's analog out.

Before soldering, also insert the capacitor between power and ground, making sure the long leg goes to ground.

![](https://cdn-learn.adafruit.com/assets/assets/000/025/813/medium800/hacks_drone-spray-sonar-finished.jpg?1433522309)

![](https://cdn-learn.adafruit.com/assets/assets/000/025/812/medium800/hacks_drone-spray-sonar-back.jpg?1433522048)

Solder the other ends of the wires to correspond with the pins on the 5-connector plug on the Pixhawk and of the cable according to this diagram from the [ardupilot site](http://copter.ardupilot.com/wiki/common-optional-hardware/common-rangefinder-landingpage/common-rangefinder-maxbotix-analog/):

![](https://cdn-learn.adafruit.com/assets/assets/000/025/811/medium800/hacks_RangeFinder_MaxbotixAnalog_Pixhawk.png?1433521434)

Although we did get sonar signals coming into the Pixhawk, we did not get so far as to use them to successfully&nbsp;control the autopilot for IRIS+ for this project-- perhaps you can pick up where we left off!

# Quadcopter Spray Can Mod

## Fly it!

![](https://cdn-learn.adafruit.com/assets/assets/000/025/804/medium800thumb/hacks_drone-spray-crash.jpg?1448318227)

Easier said than done! This rig is very challenging to fly,&nbsp;especially indoors. Make sure you have plenty of practice before affixing the spray can, which changes the center of gravity of the bot.

# Quadcopter Spray Can Mod

## Prior attempt at standalone sprayer

![](https://cdn-learn.adafruit.com/assets/assets/000/025/807/medium800/hacks_katsu-drone-paint-sprayer-01.jpg?1433518838)

If your drone isn't so forthcoming about providing power connectors or gimbal control documentation, you may wish to create a standalone parasitic device to trigger your spray can while it's mounted on the quadcopter. Pictured above is [the "icarus one"&nbsp;version of the device used in KATSU's drone paintings](http://www.icarusone.com/yours/),&nbsp;which uses&nbsp;a 3D printed servo can mount based off [sliptonic's silly-string trigger on Thingiverse](http://www.thingiverse.com/thing:12256).

The store-bought injection-molded plastic spray mounts are really much better suited for this project than 3D printing, but for some reason it just hadn't occurred&nbsp;to me to look for such a product at the time.

![](https://cdn-learn.adafruit.com/assets/assets/000/025/808/medium800/hacks_katsu-drone-paint-sprayer-02.jpg?1433518896)

The electronics consist of the following:

- [standard servo](https://www.adafruit.com/products/155)
- [Arduino Micro](https://www.adafruit.com/products/1086)
- [on/off switch](https://www.adafruit.com/product/1092)
- [9v battery clip](https://www.adafruit.com/product/80)
- [315MHz RF receiver](https://www.adafruit.com/products/1096)&nbsp;and&nbsp;[remote](https://www.adafruit.com/product/1095)
- [half-sized Perma-Proto](https://www.adafruit.com/product/1609)

Sure, the range on the transmitter/receiver pair isn't close to the range on he quadcopter's radios, but for painting you want to be close to the action anyway so this was considered an acceptable limitation.

The code simply took two digital inputs from the RF receiver&nbsp;and used their states to turn on the servo and press the lever as well as release it:

```
#include &lt;Servo.h&gt; 
 
Servo myservo;  // create servo object to control a servo 
                // a maximum of eight servo objects can be created 
int triggerpin = 5;
int offpin = 2;


int buttonState;             // the current reading from the input pin
int lastButtonState = LOW;   // the previous reading from the input pin
int button2State;             // the current reading from the input pin
int lastButton2State = LOW;   // the previous reading from the input pin

 
void setup() 
{ 
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object 
  pinMode(triggerpin, INPUT);
  pinMode(offpin, INPUT);
} 
 
 
void loop() 
{ 
  buttonState = digitalRead(triggerpin);
  button2State = digitalRead(offpin);

// compare the buttonState to its previous state
  if (buttonState != lastButtonState || button2State != lastButton2State) {
    // if the state has changed, increment the counter
    if (buttonState == HIGH) {
      // if the current state is HIGH then the button
      // wend from off to on:
      //buttonPushCounter++;
      myservo.write(90);
    delay(15);
      //Serial.println("on");
      //Serial.print("number of button pushes:  ");
      //Serial.println(buttonPushCounter);
    } 
    else if (button2State == HIGH) {
      // if the current state is LOW then the button
      // went from on to off:
      //Serial.println("off");
       myservo.write(0);
    delay(15);
    }
  }
  // save the current state as the last state, 
  //for next time through the loop
  lastButtonState = buttonState;




} 
```

![](https://cdn-learn.adafruit.com/assets/assets/000/025/809/medium800/hacks_katsu-drone-paint-sprayer-03.jpg?1433519004)

It is this standalone device that was attached to a DJI Phantom quadcopter to create [KATSU's&nbsp;drone paintings](http://theholenyc.com/2014/04/01/katsu-drone-paintings/). A [circuit diagram is available at the icarus one site](http://www.icarusone.com/yours/).

![](https://cdn-learn.adafruit.com/assets/assets/000/025/810/medium800/hacks_KATSU-drone-painting.jpg?1433519080)

The known issues with this circuit are mainly related to range and responsiveness once the servo is engaged, depressing the spray can.

The current draw on the circuit seems to decrease the sensitivity of the RF receiver, resulting in a spraying can that can't be turned off remotely, so it sprays until it runs out of paint. This was also considered an acceptable limitation for experimentation under the circumstances.


## Featured Products

### 3DR Iris+ — Autonomous multicopter

[3DR Iris+ — Autonomous multicopter](https://www.adafruit.com/product/2199)
The new consumer-grade **3DR Iris+** is an all-in-one autonomous aerial vehicle with a compact and durable design. Stylish and powerful, Iris runs on the innovative [Pixhawk autopilot system](http://store.3drobotics.com/products/3dr-pixhawk)--the newest in advanced autopilot...

No Longer Stocked
[Buy Now](https://www.adafruit.com/product/2199)
[Related Guides to the Product](https://learn.adafruit.com/products/2199/guides)
### 5V 1.5A Linear Voltage Regulator - 7805 TO-220

[5V 1.5A Linear Voltage Regulator - 7805 TO-220](https://www.adafruit.com/product/2164)
Ah, the venerable 7805, who amongst us has not used this popular linear regulator? This big chunky regulator will help you get your 7-35V battery or wall adapter down to a nice clean 5.0V with 2% regulation. Perfect for just about all electronics!&nbsp; This is the TO-220 version, with up to...

In Stock
[Buy Now](https://www.adafruit.com/product/2164)
[Related Guides to the Product](https://learn.adafruit.com/products/2164/guides)
### Adafruit Perma-Proto Quarter-sized Breadboard PCB - 3 Pack!

[Adafruit Perma-Proto Quarter-sized Breadboard PCB - 3 Pack!](https://www.adafruit.com/product/589)
Customers have asked us to carry basic perf-board, but we never liked the look of most basic perf: it's always crummy quality, with pads that flake off and no labeling. Then we thought about how people **actually** prototype - usually starting with a solderless breadboard and then...

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

[Micro servo](https://www.adafruit.com/product/169)
Tiny little servo can rotate approximately 180 degrees (90 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 these servos. Good for beginners who want to make stuff move without...

Out of Stock
[Buy Now](https://www.adafruit.com/product/169)
[Related Guides to the Product](https://learn.adafruit.com/products/169/guides)
### Premium Male/Male Jumper Wires - 40 x 12" (300mm)

[Premium Male/Male Jumper Wires - 40 x 12" (300mm)](https://www.adafruit.com/product/760)
Handy for making wire harnesses or jumpering between headers on PCB's. These premium jumper wires are 12" (300mm) long and come in a 'strip' of 40 (4 pieces of each of ten rainbow colors). They have 0.1" male header contacts on either end and fit cleanly next to each...

In Stock
[Buy Now](https://www.adafruit.com/product/760)
[Related Guides to the Product](https://learn.adafruit.com/products/760/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...

Out of Stock
[Buy Now](https://www.adafruit.com/product/1143)
[Related Guides to the Product](https://learn.adafruit.com/products/1143/guides)
### UBEC DC/DC Step-Down (Buck) Converter - 5V @ 3A output

[UBEC DC/DC Step-Down (Buck) Converter - 5V @ 3A output](https://www.adafruit.com/product/1385)
Your power supply problems just got SOLVED! This little circuit board may look tiny but inside is a high efficiency DC/DC step-down converter which can output up to 3 Amp at 5V without the need of any heat-sink or forced cooling. (It does get a bit toasty at 3A though) UBEC stands for...

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

## Related Guides

- [Color Balancing Video Camera Light feat. DotStars](https://learn.adafruit.com/color-balancing-light-box-with-dotstar-cool-warm-white-leds.md)
- [Circuit Playground - P is for PCB](https://learn.adafruit.com/circuit-playground-p-is-for-pcb.md)
- [Trinket Bluetooth Alarm System](https://learn.adafruit.com/trinket-bluetooth-alarm-system.md)
- [Adafruit Trinket-Modded Stuffed Animal](https://learn.adafruit.com/adafruit-trinket-modded-stuffed-animal.md)
- [Your Pulse Displayed with NeoPixels](https://learn.adafruit.com/pulse-sensor-displayed-with-neopixels.md)
- [Motorized Turntable](https://learn.adafruit.com/motorized-turntable-circuitpython.md)
- [Trinket Sound-Reactive LED Color Organ](https://learn.adafruit.com/trinket-sound-reactive-led-color-organ.md)
- [LED Breath Stats Mask](https://learn.adafruit.com/led-breath-stats-mask.md)
- [Breadboards for Beginners](https://learn.adafruit.com/breadboards-for-beginners.md)
- [PyBadge Thermal Camera Case](https://learn.adafruit.com/pybadge-thermal-camera-case.md)
- [Watchmen's Sister Night NeoPixel Goggles](https://learn.adafruit.com/watchmen-sister-night-circuitpython-neopixel-goggles.md)
- [Darth Faders](https://learn.adafruit.com/darth-faders.md)
- [MX MIDI Guitar](https://learn.adafruit.com/mx-midi-guitar.md)
- [Lie Ren's Stormflower Gun Blade](https://learn.adafruit.com/stormflower-gun-blade.md)
- [MEMENTO Wireless Remote with TouchOSC](https://learn.adafruit.com/memento-wireless-remote.md)
