Fly a Mini-drone With Your Computer!




A few months ago, I watched a TED Talk where they setup an indoor arena and did some amazing things with drones. It got me thinking, and it inspired me to build something like that for myself – but on a much smaller and cheaper scale. In the TED Talk video they use an expensive real-time infrared motion tracking system made by companies like Vicon or Optitrack to measure the position of the drones, and then used a computer to calculate and send control signals to coordinate the drones.

At a high level, my setup works in a similar way, using a USB camera to track the position of a $15 toy drone, and then using the computer to send radio control signals through an Arduino and a wireless card. Excluding the computer, all the equipment cost about $85.

Watch the video above to see my computer flying the drone! The photo above shows my first setup. Read this Instructable to learn how to do it yourself!

Also check out for more details and links.

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Get the Components

To get this working, you're going to need a reasonably fast PC and the following items:

  1. ELP 2 Mega-pixel USB Camera

  2. Arduino UNO R3 Board

  3. Addicore nRF24L01+ Wireless AddiKit with Socket Adapter Boards and Jumper Wires

  4. Cheerson CX-10 Mini RC Quadcopter

  5. Cheerson CX-10 Propeller Blade Guard

The Addicore wireless card is used to send the same radio signals that the drone would receive from the joystick.

Step 2: Setup the Drone

To help the camera recognize the drone, place four paper circles on the drone. Cut out circles from colored card stock. You'll want to choose a contrasting color from the color of your drone. Then, install the propeller guards on the Cheerson CX-10 drone, and use some double-sided tape to affix three circles to the propeller guard and one to the center of the drone. Arrange the three propeller guard circles as shown in the photo, with one circle to the front, one to the left, and one to the right. The side with the power switch should have no circle.

Step 3: Setup Your Arduino and the Wireless Card

Connect the nRF24L01+ card and the adapter board, and then wire them to the Arduino Uno according to the table below:

Arduino Uno NRF24L01+ Socket Adapter Board Wire Color (in photo)
D5 (Digital 5)CEYellow
A1 (Analog 1)CSNGreen
D4 (Digital 4)SCKBlue
D3 (Digital 3)MO (MOSI)Purple
A0 (Analog 0)MI (MISO)Gray
Not UsedIRQWhite

The Arduino code is available in this GitHub repository. Now plug the Arduino into your PC and load the nRF24_multipro.ino sketch onto the Arduino with the Arduino IDE version 1.6.7.

Step 4: Setup the USB Camera

The camera needs to be mounted so that it is aimed downward at a white surface from a height of about 2 feet. I used two sheets of poster board as the white background on the table. In my first setup (shown in the top picture), I used a folding table with a piece particle board to hold the camera above the table.

The second picture shows my upgraded setup built with Plexiglas sides and the camera mounted on wooden crossbars. In the second setup, the camera is mounted in the middle, and two LED lights are mounted next to it to make the lighting conditions more consistent.

Step 5: Setup Your Computer

As you might expect there is a fair amount of programming required to get this working.

You'll need to install the following software:

  1. Python 2.7 - I recommend using the Spyder development environment from the Python(x,y) distribution.
  2. PySerial package
  3. OpenCV2

Check out my guide to installing Python and OpenCV for more details.

Now download the code from the pc-drone repository. It is currently only setup to work on Windows right now, but you should be able to work on Linux or MacOS with some minor changes.

The main program to run is, run it from the command line with python ./

You'll need to have the USB camera and Arduino connected to run this code, as specified above. Most likely it will not work the first time - you'll need to edit the code so that it sees the right video camera, and also communicates to the right COM port for your Arduino. Also, you may need to tweak your code for your specific circle colors and also your lighting conditions. This post describes the process of how the computer recognizes the circles and how to modify the color recognition thresholds.

Step 6: Make It Fly!

If everything is running properly with the script, then it is time to turn on your drone. You should see one of the lights on the Arduino Uno stop flashing and stay lit. This indicates the Arduino and drone are paired and now the computer can send signals to the drone.

Press 'w' on the keyboard to let the drone take off and hover. To make it land, press 's'. There are other sequences available as well to rotate or move the drone through a pattern. You can find the keyboard commands in the code.

The above video shows the USB camera images that the computer uses to fly the drone. The small blue square in the video indicates the target location that the computer is trying to fly the drone to. The colored circles drawn around the purple circles on the drone indicate that the computer identified the position of each circle.

I hope you enjoyed my project. Please vote for this Instructable in the Make It Fly contest!

Automation Contest 2016

Participated in the
Automation Contest 2016

Make It Fly Contest 2016

Participated in the
Make It Fly Contest 2016

Be the First to Share


    • Made with Math Contest

      Made with Math Contest
    • Multi-Discipline Contest

      Multi-Discipline Contest
    • Robotics Contest

      Robotics Contest

    17 Discussions


    Question 7 months ago on Step 6

    Hey, really cool project ! I do want to build something similar. Do I have to use exactly this camera, or can it be any other USB Camera ?


    1 year ago

    Hey there, I know that this is an old post, but I am trying to get it to work, however every time I try and launch I get:


    Traceback (most recent call last):

    File "C:\Users\hdgam\Desktop\pc-drone-master\", line 19, in <module>

    import blob_detect as bd

    File "C:\Users\hdgam\Desktop\pc-drone-master\", line 169, in <module>


    File "C:\Python27\lib\site-packages\numpy\lib\", line 372, in load

    fid = open(file, "rb")

    IOError: [Errno 2] No such file or directory: 'camera_cal_data_2016_03_25_15_23.npz'

    I have checked to see if the 'camera_cal_data_2016_03_25_15_23.npz' is there, and it is... an ideas?


    2 years ago

    I keep getting this error when I compile.

    Arduino: 1.6.11 (Windows 10), Board: "Arduino/Genuino Uno"

    C:\Users\Dhruv Suri\Documents\Gesture Quad\LeapCopter-Arduino\LeapCopter-Arduino.ino:59:28: fatal error: iface_nrf24l01.h: No such file or directory

    #include "iface_nrf24l01.h"


    compilation terminated.

    exit status 1

    Error compiling for board Arduino/Genuino Uno.

    This report would have more information with

    "Show verbose output during compilation"

    option enabled in File -> Preferences.

    Is there a way to fix this?


    3 years ago

    Hello. Does anyone know how to connect a mini drone mars the pc to program with scratch.


    Sverd Industries

    3 years ago

    Amazing project! What do you think of running the whole thing on an intel edison? They can handle python and USB cameras, as well as arduino code. It also comes with buiilt in wifi so you won't need a wireless card.

    Would be cool to see the whole thing on a small self contained unit!

    1 reply
    perrytsaoSverd Industries

    Reply 3 years ago

    It would be nice to be able to run it all from one self-contained unit. I am not sure if the Intel Edison is powerful enough to handle all the vision processing.

    A separate wireless card would still be needed since the CX-10 drone doesn't use standard 802.11 wifi, it uses a proprietary chip compatible with the nRF24l01 card I used. The nRF24L01 card can interface with the Intel Edison easily enough though.


    3 years ago

    This is a really cool project. I'm wondering, could you bypass using the Python script and just send the commands via the Serial Port in the Arduino IDE?


    3 years ago

    hi ,

    i am having error running the code,i have attached an image file ,pls guide me on this


    2 replies

    Reply 3 years ago

    Hi KrunalP19,

    I couldn't read your screenshot because it was too blurry. I'll PM you my email so we can discuss more.



    3 years ago


    Can i use sony ps3 eye webcam for motion detecting ?



    1 reply

    Reply 3 years ago

    Yes, I think it could work. The PS3 eyecam has good latency and FPS rate, but it's image quality and color is not that good. Some adjustments in the software may need to be made to accommodate those differences versus the ELP camera I used.

    Check out my article where I compared the PS3 eyecam to some other USB cameras:


    3 years ago

    Impressive project. There is a lot to learn here: using OpenCV2 to track the drone with camera input to a PC; communicating with the drone's receiver using a compatible transmitter and understanding the command format; and closed loop control dynamics. Not a simple undertaking.
    1 reply

    Reply 3 years ago

    True, there were a lot of things to bring together to get it to work, but a lot of the heavy lifting was done with open-source software. The computer vision code was made much easier by using the OpenCV2 library. The Arduino code to send signals to the drone receiver only required some minor changes to accept commands via the PC's serial interface. The only stuff I had to write from scratch was the closed-loop control which turned out to be four relatively simple independent PID loops. Anyone with the willingness to do some hacking in Python should be able to do it!


    Reply 3 years ago

    RadioShack will usually have an arduino, if not then I would go to Amazon