Or how to become a drone developer without mortgaging your house.

Here is how to make a small, indoor/outdoor quadcopter that you can
fly with either:
* an android phone or tablet
* a legitimate remote
* via your own processing (http://processing.org) sketches on a PC
  (or Android device)

There are lots of optional steps in this project - for example, you
can skip building the quadcopter, and buy one instead - you will still
be to use the Arduino based radio to control it from your
phone/laptop/tablet.  However if you go this route you will miss the
satisfaction of combining the ancient chinese arts of bamboo lashing
and cheap mass manufactured electronic toys...

However you go about it, this is a reasonably cheap project, the most
expensive part other than my laptop and tablet is an Arduino DUE and a
cheaper device could be used if desired.

The ability to write your own code to fly the copter make this more of
a drone than many remote control projects, but you will need to
develop your own code to actually decide what throttle, rudder,
aileron and elevator commands to send it when - a work in progress
based upon a 'Ground station' camera tracking the copter from
underneath is included, but it doesn't fly it yet!

As a simpler exercise for the reader, you can also look into adding
forward/backward/left/right FLIP buttons to the android remote.

Taster video 1: Drone controlled by tablet:

Taster video 2: Onboard footage from flipping (and crashing)

This work was inspired by the 18$ quadcopter thread on rcgroups
(http://www.rcgroups.com/forums/showthread.php?t=1710948) - take a
look at rcgroups for plenty more inspiration.

It also makes use of plenty of other people's work, but most
immediately the processing-serial-android library
(https://github.com/inventit/processing-android-serial/) and the
hubsan X4 and A7105 code from the deviation project

Step 1: Approach, materials and safety.

This project leaves all the hardwork of copter flight control, radio
receivers, Electronic Speed Controllers, IMU's and so on to a single
part from a commercial RC copter, the Hubsan X4.  This, and other
parts are all availble as spares, itemised below, however these
little hubsan copters are fun toys in their own rate, and are probably
worth the relatively cheap (~£35) asking price just to get the practice
flying, and they come complete with one battery, spare propellers,
charger & remote.  You should still order spares to build your own

This assembly approach means you get to the stage of flying, and
coding flying routines much quicker than most and is argubly
cheaper as well.  It also means you have to know less about the
fascinating arena of remote control aircraft in general and
quadcopters in particular - so you can and should rectify this by
taking a look at some of the great Instructables on the subject!

The same thing can be done with other brands' parts - in particular
anything that Deviation supports would probably be an easy enough port
to Arduino.  In general, everything here can be done much better -
plenty of room for the reader ;)

A word about safety- big quadcopters are very dangerous.  If you've
got the stomach for zombie movies then you'll find plenty of evidence
for this on the web.  Anything under the control of a collection of
home brew electronics can go haywire.  Flying is tricky for everything
that isn't born to it (let me tell you about the birds and the
bees...) - that includes you and your code - you will crash your

Fortunately these little copters are unlikely to give you anything
worse than a paper cut, but still please do keep the safety and sanity
of yourself and yours in mind when flying - kids, pets and
unenthusiastic partners all deserve to relax without a careening
copter in the face every few minutes.

Also - soldering irons are hot, batteries can explode, kebab skewers
and couches should be kept separate at all times and your neighbours
might punch you if you fly a camera into their backyard.  Which is
both fair and reasonable - if you like people watching find a street
corner cafe and develop a taste for strong espresso and croissants -
sometimes the traditional forms are the best!

* Laptop with Processing and Arduino environments - the instructions are
   Linux specific, but should all work on other platforms with the minimum
   of faffing. 
* Android device that supports USB host mode.  Tested on Motorola Xoom.
* Soldering iron and related gubbins - solder, helping hands etc.
* Scissors
<p>sir can u send me the codding ... pls if u have java code pls send me that ... pls sir i wait till ur next reply my id smartavinash2011@gmail.com</p>
<p>hello.. i dont have an arduino board. is there a possibility to build this with a raspberry pi?</p>
<p>can you send me a detailed explanation on making and controlling a drone with an android app to prashant.ps444<a href="mailto:pkompally@gmail.com" rel="nofollow">@gmail.com</a>. Please send me a detailed explanation please</p>
<p>can you send me a detailed explanation on making and controlling a drone with an android app prashant.ps444@gmail.com. Please send me a detailed explanation on this only. please</p>
<p>can I use arduino uno?</p>
<p>can I use arduino uno?</p>
<p>can I use arduino uno?</p>
<p>can you send me a detailed explanation on making and controlling a drone with an android app aaronyong811@gmail.com. Please send me a detailed explanation on this only. please</p>
<p><a href="http://processing.org/tutorials/android/" rel="nofollow">http://processing.org/tutorials/android/</a></p><p>Hi,</p><p>This page has an error. Pls help!!! :))))))))</p>
<p>PLEASA CAN YOU SEND ME DETAILS ON CODING THE ANDROID APP </p><p>I NEED IT FOR MY FINAL PROJECT </p><p>HERE IS MY EMAIL</p><p>bosoomama@gmail.com </p><p>thanks look forward to received a reply from you </p>
<p>can you send me a detailed explanation on making and controlling a drone with an android app to <a href="mailto:pkompally@gmail.com" rel="nofollow">pkompally@gmail.com</a>. Please send me a detailed explanation on this only. please</p>
<p>Is there anything I have to change in the code if I am using an arduino mega 2560? I have everything connected and I have quadruple checked the connections and made sure they are correct, but the LEDs do not stop flashing on the receiver.</p>
<p>I bought all materials to built the quadcopter, and I achieved to join radio with receiver. But, despite that LEDs stop blinking and looks like join is working, when I use App for Android o Processing, nothing happens.</p><p>I'm working with 3 SPI pins, and I used these resistors: 2.2 Kh, 3.3 Kh and 4.7 as drdanny had mentioned in comments, only with them, join between radio and receiver success properly.</p><p>Also, I had tried with the code shared by drdanny, and still not working.</p><p>I suppose that, if LEDs stop blinking, the join is working and the circuit is well built.</p><p>What is wrong?</p><p>Somebody could give me suggestions?</p>
<p>Heya,</p><p>Sorry for the slow response!</p><p>I've not worked on this for quite a while now, so I'm going from memory a bit, but as you've worked out it sounds like the comms between radio and arduino, and radio and copter are working, so that leaves the PC/Android-&gt;Arduino leg as suspicious.</p><p>To confirm this 100% you could try changing the arduino code so that the throttle is fixed at 20% once binding is complete. I'd probably do this with the propellors taken off the copter ;)</p><p>If this works, then you know its an issue with the serial comms, and we can dig deeper from there!</p><p>Hope that helps</p><p>shez</p>
<p>Or, Is there something special to do to apps work properly?</p>
<p>I have some questions about this project.</p><p>1. Does hubsan receiver have any sensor like gps, radio, acceleration, etc.?</p><p>2. Can I control flight with arduino, and If I can, How I can do it? I want to try autonomous flight, programming with c++</p>
<p>Hey I too am using C++ to fly the quadcopter. My transmitter just got here so I still have to put that together. Once I do I will let you know how my C++ program goes!</p>
<p>Really?</p><p>How much time did you wait to receive your transmitter? I ordered mine about one month, and I still waiting for it.</p><p>I want to simulate autonomous flight with drones. I have all materials except the transmitter.</p><p>And I don't have idea how implement my own program. I know programming and a little of Arduino, but I don't know how control the drone.</p>
Hi,<br>I'd advise reading the instructable, which will give you a good intro and answer most of these questions, any further questions you have afterwards, ask away!<br><br>Cheers<br>Shez
So, I've put a lot of it together, but I'm having an unbelievably hard time soldering the wires onto the radio signal thing. Not the one that goes on the drone, but the one attached to the arduino. Why they didnt just put holes where the wires should go instead of those stupid indents is completely beyond me. <br><br>Do you have any advice with this? I've been trying to get it for the past few days but they just aren't staying. Or maybe a different way to attach it to a breadboard.
Heya, I think I soldered on little breadboard compatible headers rather than wires, something like these: http://oliversmith.io/wordpress/wp-content/uploads/2011/09/DSC04685.jpg<br> <br> Whether that's easier or not I don't know!<br> Cheers<br> Shez
<p>Hey so I am working on writing my own code to communicate to the arduino in c++. What kind of commands do I need to send to the arduino? </p>
Hey,<br><br>Can't really say without a lot more info about your set up and what you are trying to achieve - however the processing code should be an easy place for you to get inspiration as if you know c++ reading it should be a doddle.<br><br>Cheers<br>Shez
<p>Okay so I actually looked through the arduino code and it looks like it gets values for rudder, throttle, aileron, and elevator. I guess my questions is what are the physical quantities these values represent?</p>
<p>Hey,</p><p>Most of my answers to this sound a bit smart assed, but fundamentally:</p><p> - The same things as they do when flying with the normal controller </p><p> - The same as they do for any quadcopter (google those terms you'll get better pictures than I can draw )</p><p> - If you really mean 'physical quantities' then they affect the rate at which the propellers are spun - after all a fixed pitch, unarticulated quadcopter doesn't have anything else to vary. The relationship between the commands and the spinning is more complex than we have to worry about thanks to all the gyro's, accelerometers and computing power hidden in the little toys.</p><p>Hope that helps somewhat!</p><p>Shez</p>
<p>Thanks! No worries about sounding smart assed. I expected as much for asking questions that seemed obvious.</p><p>James</p>
<p>I have an Arduino Duemilanove. Is this good enough or do I have to also buy the DUE?</p>
Hey,<br><br>the radio chip operates on 3.3v logic, whereas the Arduino Duemilanove operates on 5v.<br><br>If you are comfortable (or don't mind becoming comfortable!) with converting the logic levels, or converting the Arduino Duemilanove to 3.3v I think it should work....<br><br>Cheers<br>Shez
<p>Thank you! Do you know how I would go about doing this? I'm sure it says somewhere online</p>
<p>Google 'logic level converter', 'voltage divider' and have a look at <a href="http://www.instructables.com/member/NicholasH1/" rel="nofollow">NicholasH1</a>'s post below. It may also be possible to take your microprocessors life in your hands and rejig it to run at 3.3v - there may be instructions on the arduino.cc site.</p><p>I've not done any of the above, so that is about the limit of my helpfulness, sorry!</p>
<p>Tried with arduino nano and no luck ... i used the pins but they dont connect ... should arduino nano had different codes ? </p>
<p>could it work with this a7105 ?</p><p><a href="http://www.banggood.com/A7105-XL7105-SY-B-2_4G-Wireless-Transceiver-Module-CC2500-NRF24L01-p-922597.html" rel="nofollow">http://www.banggood.com/A7105-XL7105-SY-B-2_4G-Wir...</a></p><p>thanks</p>
great project! thanks :) <br><br>is there a way to control the hubsan with python language ? <br><br>thanks
<p>yay I have found one ! will try</p><p>https://github.com/chpatrick/hubsan</p>
<p>Is there any way, if possible, to send a gyro reset code via the Arduino. I don't own the remote for the H4, I'm only using a phone. My octocopter is drifting diagonally and I'm pretty sure it's the gyro which is set incorrectly. The copter also spins around and around.</p><p>Thanks for this AWESOME tutorial!</p><p>-N.G.</p>
<p>I would have to recommend trying to balance it properly first, ie be sure your battery isn't throwing it off, doesn't take much with such little birds. Then bind up and set throttle=0 yaw=0, elevator =7F, aileron=0<br>delay maybe 20us<br>aileron=FF<br>delay<br>aileron=0<br>delay</p><p>repeat that about 5x in a row, if you don't get the blinky lights, try setting yaw to FF in the first line...</p>
<p>Hi, </p><p>If there are two receiver in the same room and only one transmitter, the two receivers will receive a communication ?</p><p>How does it work?<br><br>Thanks,</p>
<p>Incredible project.</p><p>If there are two copters in the same room and only one transmitter, the two copters will be controlled?</p><p>How does it work?</p>
<p>When buying the motors do they have to be clockwise/counter-clockwise or is there a way to wire it that makes it rotate a certain direction?</p>
<p>Changing direction on:</p><p>DC-motor: switching polarity (+ on - and vice versa)</p><p>Three-phaze motor: switch places of two wires</p>
<p>This is cool! I haven't built a custom quadcopter yet, but I have been using these Arduino instructions to control an Estes Syncro / Proto X.</p><p>I went ahead and set this up slightly differently--I got it working using 4-wire SPI, rather than 3-wire. This made it a lot easier to interface with the 5v arduinos, and also removed the guesswork from the resistor values. For a Due (or other 3.3v arduinos), 4-wire SPI doesn't require any resistors at all; for an Uno (or other 5v arduinos), a simple voltage divider (11k from MOSI to SPIO, 22k from SPIO to ground) handles writing, and reading (from GPIO1 on the left side of the radio board) doesn't require any resistors.</p><p>Three aspects of this took me a while to work out. First, there's commented-out code in the A7105_Setup function that claims to set it into 4-wire mode, but there's an error in it. It writes the value 0b0110 to register 0x0b. This is the correct register, but the wrong bit pattern--the bit pattern should be 0b011001, where the final two bits are 0 for non-inverted output and 1 for enable output. In hex, this value is 0x19. I probably would have caught this sooner, but the error codes in the Hubsan initialization routine all check for specific error flags set to 1...so if all your &quot;read&quot; calls are returning 0, the system thinks initialization has passed.</p><p>I added this routine to read the chip's &quot;ID&quot; register. This value is 32 bits long, so I write it into an array of uint8_t variables:</p><blockquote>void A7105_ReadChipID(uint8_t chipID[]) {<br> CS_LO();<br> SPI.transfer(0x46); // 0x40 | 0x06<br> for (int i = 0; i &lt; 4; ++i) {<br> chipID[i] = SPI.transfer(0);<br> }<br> CS_HI();<br>}<br></blockquote><p>You call it like this:</p><blockquote>uint8_t chipID[4];<br>A7105_ReadChipID(chipID);</blockquote><div>If all four blocks of that are zero, there's something definitely wrong with the connection to the chip. I think this is akin to the MAC address for the chip--it should be constant for any specific a7105 chip, but it should be different for any two a7105s.</div><div>Third, and perhaps most importantly, you can't rely on Serial.print in this sketch. Other people have pointed this out as well. Any Serial.print instructions in the sketch will make it unstable. You should comment out any Serial.print instructions before testing the sketch. When the sketch was half-working--talking to the radio correctly, but getting interference from the Serial.print commends--the front two lights on the Estes Syncro would blink in sync with each other, rather than the alternating flash they do when the craft can't find any radio. If you get to this point, persist! You've almost got it working.</div><div>I'm planning to use this to build a more useful controller for the Syncro. In particular, I'm going to separate the throttle control from the yaw controls, because on the stock controller it's hard to turn without also bumping the throttle; I'm going to make the throttle control relative rather than absolute, but add a &quot;panic&quot; button to set the throttle to zero; and I'm going to add buttons for extra features, like buttons to adjust rate settings, buttons for flips, and so on. The Hubsan controller offers most of these features, but I'm confident I can produce something superior now that I have the freedom to tweak it to my heart's content.</div><div>Here's a photo of my setup. (The thing under the radio is just a little board I etched to make the radio breadboard-friendly, as mine's pin connections were spaced wrong for my breadboards, and the thing in the corner is a pot I wired up to act as a throttle input for testing.)</div>
<p>so i'm working with the Proto X. i'm able to get the lights to stop blinking, that all,</p><p>i am geting a ChipID. </p>
There are a couple of things I forgot to mention in my comment. I thought I'd posted an additional note to cover that stuff, but apparently I forgot. First, there are a lot of calls to A7105_Reset in the code. That in itself isn't a problem, but I think the radio forgets about 4-wire SPI after a reset. I fixed this by adding an A7105_Setup call after each call to A7105_Reset, but it probably makes more sense to chain a call to A7105_Setup at the end of A7105_Reset, which would guarantee it always resets to the known-good state. Otherwise Read calls will go back to getting zero at all times if you're using 4-wire. In particular, there's a call to A7105_Reset in initialize() in hubsan.ino. This could be the problem, because initialize() will still complete if the Reads are all zero--it only looks for zero values as an &quot;okay&quot; state--and will probably finish binding the copter, so the lights will stop blinking. But since the code will never detect error states from the radio, it's unlikely to keep communicating properly with the copter after this. (I'm not certain if hubsan_cb() requires any nonzero values, but if it does, this would also prevent it from communicating with the copter if the wire mode was reset.)<br> <br> The second thing is that the configuration of the sketch in main.ino seemed weird to me too, so I rearranged that--I moved the setup and initialization to a setup() function, and made the while(1) loop body into the entire loop() function. That made more sense to me. &nbsp;Finally, I didn't use the Serial.read value settings that the original author did--I was having enough trouble with Serial changing the timing of things that I decided to just hook up a potentiometer to analog zero and use that for the throttle setting as a proof of concept. That's what worked for me. I haven't used the original author's Processing sketches with the code or with the proto-X.<br> <br> The entirety of my altered &quot;main.ino&quot; code, then:<br> <br> void setup() {<br> &nbsp; Serial.begin(115200);<br> &nbsp; A7105_Setup();<br> &nbsp; delay(2000); &nbsp;// gives two seconds to open serial monitor to see chip id<br> &nbsp; uint8_t chipID[4];<br> &nbsp; A7105_ReadChipID(chipID);<br> &nbsp; Serial.print(&quot;Chip ID: &quot;);<br> &nbsp; for (int i = 0; i &lt; 4; ++i) {<br> &nbsp;&nbsp;&nbsp; Serial.print(chipID[i]);<br> &nbsp;&nbsp;&nbsp; Serial.print(&quot;\t&quot;);<br> &nbsp; }<br> &nbsp; Serial.println();<br> &nbsp; initialize();<br> }&nbsp;<br> <br> void loop() {<br> &nbsp;&nbsp;&nbsp; int throttlereading = analogRead(0);<br> <br> &nbsp; &nbsp; // set global control variables for the quadcopter<br> &nbsp;&nbsp;&nbsp; throttle = throttlereading / 4; &nbsp;// Scale 0-1023 down to 0-255<br> &nbsp;&nbsp;&nbsp; rudder = 0x7f; &nbsp; &nbsp; &nbsp;// Midpoint setting<br> &nbsp;&nbsp;&nbsp; aileron = 0x7f; &nbsp; &nbsp; // Midpoint setting<br> &nbsp;&nbsp;&nbsp; elevator = 0x7f; &nbsp; &nbsp;// Midpoint setting<br> &nbsp;&nbsp;&nbsp;<br> &nbsp; &nbsp; int hubsanWait = hubsan_cb();<br> &nbsp;&nbsp;&nbsp; delayMicroseconds(hubsanWait);<br> }<br> <br> Once again, note that I altered &quot;initialize&quot; so that it would call A7105_Setup after A7105_Reset, so that the code would read error states correctly.<br> <br> Hope this helps.<br> -Nick
<p>Hey Nick,</p><p>Thanks for the help! so for no go :(</p><p>One thing I tried printing the id be for and after paring, is this normal?</p><p>Id be for paring is all was,</p><p>ID: :85:32:16:65</p><p>if after paring is,</p><p>ID: :0:0:65:167</p><p>-tPt</p>
<p>I was ablet to get woking, using a teensy 3.1 <a href="https://www.pjrc.com/teensy/teensy31.html" rel="nofollow">https://www.pjrc.com/teensy/teensy31.html</a></p><p>my testing loop</p><p>void loop() { </p><p> startTime = micros(); </p><p> boundcnt = Get_state() &gt;= 8 ? boundcnt + 1 : 0;</p><p> hubsanWait = hubsan_cb();</p><p> Serial.println(boundcnt);</p><p> finishTime = micros();</p><p> waitTime = hubsanWait - (finishTime - startTime);</p><p> delayMicroseconds(waitTime);</p><p> startTime = micros();</p><p>}</p><p>i allso in hubsan_build_packet() i set,</p><p>packet[10] = 0x19; vs 0x64</p><p>used this to test the lights and throttle</p><p>if( cnt &lt; 100 )</p><p> {</p><p> packet[9] = 0x0e; // LEDs on, flip on for the 100 first frames</p><p> cnt++;</p><p> }</p><p> else{</p><p> packet[9] = 0x02; // LEDs off, flips off</p><p> packet[2] = 0xaa;</p><p> }</p><p>and i have lift off,!!</p>
Hey that's great work and will really help others who try and reproduce, thanks for contributing!<br>Cheers<br>Shez
<p>Thanks for DYI it is great,</p><p>i just don't understand why you need the resistor for 20K?</p><p>and can you please explain how to connect it to arduino nano/leonardo?</p>
<p>Thanks for the awesome project. I've managed to build it. I am interested in the android processing serial library you've used. I've tweaked your processing code to reverse the controls as they were backwards when using it on a Nook HD. I can't seem to get the app to connect to the Due. Having gone to inventit processing android serial github, i noticed you had had the same issue as well, but have hacked the library to get it working. I was wondered if you might be willing to share your hacked library. Thanks! </p>
<p>For those interested, i've just flown my Hubsan x4 with my laptop using this tutorial. But instead of the DUE i tried to make it work with the <a href="https://www.sparkfun.com/products/12587" rel="nofollow">Sparkfun Arduino Micro Pro 3.3v</a> which by comparison to the DUE is amazingly tiny, about the double the size of the A7105 radio, </p><p>And it seems to work, further testing is of course requiered and i will return with my finding. Now to wait 'till after exam to dig into the coding :P</p><p>Thanks for a great guide!</p>

About This Instructable


487 favorites


More by shinyshez: Easy Android controllable, PC Interfaceable Relatively Cheap Mini Quadcopter (or Octocopter!) Drone...
Add instructable to: