How-to Users Projects

Low Cost Arduino Based Auto-Stabilizing System

There are a lot of choices when it comes to picking a flight controller for your quadcopter.   If you are looking for a low cost way to auto-stabilize your quadcopter, this is the guide for you!

Before we get into the details of this project, let me say there are cheaper ways of creating a auto-stabilizing system such as using the sensors out of the Nintendo Wii controllers, but I choice this method for it’s simplicity and small form factor.  The skill level for this project is Intermediate.  This guide requires you to have experience uploading Arduino code and reading schematics.  That said, let’s get started!

The parts list is as follows:
1 Arduino Nano Board / Arduino Nano from UK store
Jumpers Wires Set
Sparkfun 6DOF IMU
Logic Level Converter
Break-Away Headers

This project is based on the Arduino Nano board.   This board features a ATmega328 the same micro controller as the Arduino Uno.  The Nano pack the same functionality as a Uno (minus the DC power jack) all in a small form factor.   The sensor board (IMU) is the Sparkfun 6DOF IMU.  This IMU contains the 3-axis ADXL345 accelerometer and the 3-axis ITG-3200 gyro.  The IMU is used to sense the orientation of the quadcopter in space.   The next component in our parts list is the Logic Level Converter board.  This board converts a 5V signal to a 3.3V signal or convert a 3.3V signal to a 5V signal.  The Sparkfun IMU is 3.3 volts board and the Nano is a 5 volt board.  In order for the Nano to read the IMU’s data we need to bring the IMU signals voltage from 3.3 volts to 5 volts.

I am using a breadboard and jumper wire for demonstration and experimenting purposes.  If you choice to use this flight controller in a quadcopter, please use a ProtoBoard and solder your connections.

Let’s get started

First, place the Nano board along the center of the breadboard.  Each row of pins need to be on each side of the center divide (See photo).  Note: Each numbers row is electrically connected.   The center divide separates the numbered rows electrical connection.

Next place the Sparkfun 6DOF IMU along the F column.  Place the Logic Level board across the center divide.

Before we wire the components, we need to upload the flight controller code to the Nano.
The firmware and software I am using is the Aeroquad software.  The Aeroquad platform uses regular Arduino boards to run their flight controller software.

  1. Download the firmware
  2. Download Arduino version 0023
  3. Download the Software for PC or Mac
  4. Upload the firmware via Arduino.
  5. Install the software for your PC or Mac

Once the code is uploaded to the Nano and the software is installed on your computer, we can now wire up the boards.

The wiring in this picture looks scary but it’s actually pretty simple.

Use the following schematic diagram to wire your board with the jumper wires.  For this guide it is not necessary to wire the motors, RC Receiver and RC battery.   I have included those connections, if you wish to proceed further with this project.

Open the Aeroquad software type in ‘57600’ for the baud rate. Under ‘Com Port’ take note of the listed ports. Connect the Nano board to your computer. Click refresh under the ‘Com Port’ and select the newly listed ‘com port’ and click connect.

Once connected a 3D quadcopter will appear on the screen. Move the flight board around, the onscreen quadcopter will mirror your boards orientation.

This guide stops short of wiring the motors and RC receiver.  These connections should be soldered, but if you wish to experiment further and wire the motors and RC receiver here’s how.

Take the Straight Header pins and break them off into 3 pins headers. Place the 3-pin header into the female connector of the ESC.  Make the signal wire (usually the white wire) of the ESC is connected to the signal wire from the individual pins of the Nano board.

For the R/C receiver order this Jumper Wire and connect one female end to the signal row of your receiver.   Cut off the other female end and solder the individual wires to their respective pins on the Nano board.

137 replies on “Low Cost Arduino Based Auto-Stabilizing System”

Error problem resolved. I deleted the code and downloaded a fresh one and it works now. Another question: can I use the Arduino Mega 2560 for this project as I already have one. If yes what other electronics Do I need?

Yes, I think it is possible to use a Arduino Mega. The code supports the Arduino Mega, however I am not sure if the pins are the same for the Arduino Mega and Mini. You may have to define the Arduino Mega in the code and change the upload board to the Arduino Mega 2560. If you do proceed with the Arduino Mega, I would like to know how you made out. And no other electronics is needed.

i am trying to use the code you provided and giving me hundreds of errors ! should i do something special before uploading the code

i am using arduino uno …

Make sure you select the Arduino UNO as your board. Also you have to change the code to the arduino UNO. What is the error you are receiving.

It would be possible to use the 3.3V output of the Arduino and dispense the logic level converter?
Why you didn’t used this output? Instead of the 5.5v.

The issue is that the Arduino’s inputs are looking for a 5v signal. If you were to use the 3.3v output from the Arduino you are only going to have a 3.3v signal going into the Arduino’s inputs. You need the logic level to scale up the signal for the Arduino to read it correctly.

You can connect a barometric sensor and a magnetometer to stabilize both axes X and Y axis Z
best regards

To build a full quodcopter, are there any other electronics that I need other than these three parts? I have an Arduino UNO which I was going to use instead of the NANO. Other than the motors, R/C receivers, and battery what do I need?

Basically, what I’m asking is, what does this low-cost alternative replace in your parts list under ‘Intelligence (Electronics Guide)’? From what I understand is that it replaces the ArduPilot Mega and ArduPilot Mega IMU. Is that right?

I’m a complete beginner at this, but I like the trial-and-error aspect of making everything myself.

The Arduino Nano or Uno is the substitute for the ArduPilot Mega. The Sparkfun IMU is a substitute foe the ArduPilot Mega IMU. As far as thing you need for auto-stablizing flight, all you need is a Arduino Board, the Sparkfun IMU and Logic Level board.

i’m a beginner too, i’m going to make this project, can you show me a complete scheme that shows the esc connection and the tx module. Thanks a lot.

I calculated the total cost of these 3 modules about 100€, what do you think about this module selled by hobbyking
HobbyKing Multi-Rotor Control Board V3.0 (Atmega328 PA) less than 20€?

I haven’t tried the HobbyKing Flight controllers. What I can say about the parts in this tutorial are high quality parts. I am interested in knowing how good the HobbyKing Control performs.

I’m having a problem with running the AeroQuad It keeps coming up with “AeroQuad Alert Could not find the LabVIEW Runtime, you may need to install it.” I have installed it. Twice. What am I doing wrong? I’m also unsure of how to upload the firmware to the Arduino. I’ve downloaded the firmware but there are 25 files in the folder and I’m not sure which one to use to upload to the Arduino Nano.

You will want to open the Aeroquad.pde in the Arduino software. Then select the appropriate Arduino board from the menu and serial port. Then click the upload button.

Did you solve this problem?
I know this was like 2 years ago, but if you did i would appreciate help in solving it!
Im using a Mac, and i am literally in the EXACT same situation with the software.

But my arduino dosnt have the same ports?
I am new to quads so do you think my this quad wil fly or i should go by a shield first?

Will buy Urgently.


If you have a Arduino and the other parts already, then it is free to try and get it working. You certainly need to have some knowledge on wiring electronics and programming an Arduino. If you feel comfortable enough with the tutorial then I would give it a try.

hi,,,i m using this software for the first time…..
i m getting an error while trying to connect my arduino uno rev3 with aeroquad… do need to do anything with my uno??? first??

no… the code does not even getting uploaded into my arduino>>>>>
when i press the upload button the ide says that it has errors>>>>>>>
will it problem in my bootloader???

For controlling signal coming to the arduino from receiver, do we need to use timer or how to capture the PWM signal coming from radio controller receiver?
why did you connect the receiver output to pin number 2,4,5,6,7,8? is these pins contain some special feature or what?


Dear Russell,

How to read 6 channels while there is only one input capture in the arduino nano? is it possible to read all signals simultaneously? like reading Pitch and throttle at the same time? and how?


Why do you have only one input left on the Nano? Any of the pin can be an input pin. If you want to read more than one input on the same channel then you will have to use “serial” communication to concatenate various signals.

I am not saying that I have only one pin left, I meant there is only one Timer to be used for capturing PWM signal from receiver. my question was how to capture PWM signal coming from receiver using Arduino nano like you use ?

Nice write up!

However, I believe you need to connect the 3.3V on the sensor and on the line converter to the 3.3V on the arduino — not to each other.

Hi Russel,

Why don’t you use I2C instead ? much easier and only 2 wires needed.

It is also possible to use both 5v and 3.3v are analogue inputs. You can use the VRef input for setting the correct reference voltage level.

Just my 2cts


Hello, that’s an awesome website that you have got here! I have tried to implement this system myself, using analog gyros and accelerometers. I am experiencing a lot of magnetic disturbance once I get the motors running, and hence the angle readings are all getting distorted. Did you not experience any such effects? Do you think that digital IMUs are immune to such problems?

Are sure the reading are not due to vibration? Analog and Digital accelerometers and gyros work the same way but a digital accelerometers have ADC to convert the signal to a digital signal.

i just want to ask how to relate the values obtained from the 6 DOF to the motor speed so i can stabilize the quadcopter? what are the common equations used in stabilizing the quadcopter?

Hi Russel,

Im using your code with the Arduino Uno R3
Had to make some minor adjustments to find the gyro and acclerometer on the serial monitor. Having an issue with aeroquad and a driver i seem to be missing, managed to sort it downloading driver now.

However my problem is that regardless of the aeroquad configurator. after i upload the code to the board. remove the usb and attach my battery, i cannot seem to get the gyro to calibrate or the motors to arm. Im using a Topfire R/C 6 channel but after the intial start up sequence i go to arm and there is no confirmation beep. even throttling up nothing spins for me. After unplugging all the motors and re plugging this time listening to their beeps. I have not managed to get any further.

Is there any paramters that i need to adress in this Aeroquad Configurator or should i be able to just fly it.

Really stuck so please reply asap

regards Ben

Looking at the configuration i see a motor setup so after ive uploaded the code to the board do i need to upload from the configuration aswell?

Hey, I’m a Videographer & I’ve been trying to make a Quadcopter for my GoPro H3 with useing an Arduino. I’ve seen people use an XBee Pro for wireless controll, you think this software will work with XBee instead of a Regular RC controller if so there’s soooo much more that can be done with this setup. Like useing pan & tilt on cam, GPS, etc. Can you help me with this? I’m great with elecronics but not so much with the programing side, thank you for any help.

You can use Xbee’s for telemetry. For controlling the quad via Xbee along with pan & tilt controls, GPS you will want to use a ArduPilot Mega or similar controller. The nano simply doesn’t have enough inputs and outputs.

I am trying to upload it but i get lots and lots of errors in the AEROQUAD.H file. Can someone help me?
Best regards

Same problem here. I connected Arduino nano and tried to upload Aeroquad Firmware given above. But Error shows in Aeroquad.h that are

” are not declared in this scope”.
secondly “byte does not name a type”.

need help.

Do we still need 4 ESC to run the four motor i assumed we still need them but in case, and my other question is do we need to run the power and ground from the r/c reciver and of yes where do the go?

Hi Alex,
Offcourse! we need ESC for each motor on Copter installed (e.g Xcopter need 4ESCs and hexcopter needs 6ESCs).

About the second question, i m not sure what you asked, but the reciever gets power from Flight Controller and Flight controller gets power from ESCs (There is a power supply(5V) inside ESC called BEC).

Thank u so much for this write up… Getting ready to do my build in about a week and had some questions…
1. Does the esc only connect to the board with one wire?
2. If the other 2 wires do connect where do they go?…

Hello, I am new to all this UAV stuff but I am keen to learn and play around, what I wanted to ask is would I be able to use a Arduino Mega 2560 Board and the use a MinIMU-9 v2 Gyro, Accelerometer and Compass?
What I would like to also ask is would there be enough input and out puts to later mount a gps etc to make fully unmaned.
Thanks for your time.

I have a hobby king multirotor v3 board.
I found a way to upload arduino code to that board.
Will the code work??

Can i use 6 channel PS2 controller to control the flight…if yes can u tell me more abut the connection to be made when connecting it with rx mode…?????

I believe you could, using something like an OpenLRS transmitter (Which is just an arduino with a TX module in it) and look up the PS2 protocol. If you are talking about the PS2 as in the peripheral interface, then some libraries for ardunio have already been made for PS2 keyboards and mice.

I uploaded the code to my uno, however the configurator can’t connect.
When i send a Q or S via the serial monitor it does respond but when i use the configurator i get VISA: timeout expired before operation completed.

i just want to ask how to relate the values obtained from the 6 DOF to the motor speed so i can stabilize the quadcopter? and how to give a command from remote to quadcopter?

How can I replace normal RC with Xbee? Can you explain the procedure?
To which pins I can connect the Xbee module? How to create a PC interface of control using Xbee? Will I be able to stream the video data recorded in Xbee to my PC?

I am newbie and any help is greatly helpful.

Thank you.

For this project you will need a radio. Xbee’s can provide telemetry data and depending on flight controller be able to send commands to the aircraft. For video streams you will need a separate video transmitter and receiver. The bandwidth of video is too large for Xbee’s bandwidth.

Hey, hope you succeeded using a Xbee.. I’m thinking to do the same.. please help if you’ve any links or information on how to do this..

i am an E&C eng. student . i want to make a quad copter as my last year project.please guide me that how can i achieve this.? and how can i make this.? please guys help me..

The Nano uses a atmega318. If you are not going to use a Nano, then you you will have to match up the pinout with your board and the code. You will have to use ESC’s to control your motors. There is really no way around it.

Can I use the 10dof board to simply hookup to the UNO and still use the AEROquad software or does the software not support it

hello everybody
I had an error for compiling the firmware could you please help???

error: ‘BYTE’ was not declared in this scope

it’s not used any more by arduino!! what could i do??


I would like to know if there is a way to use the same project on a helicopter and use it the same way as the quadcopter? thanks!

Is it possible to use IMU to correct the position of an UAV because of the drift? In the cases where GPS unit is not precise enough.

Thank you.


I want to use 9DOF IMU with arduino mega 2560 is that possible ???
what are requirements ???? what should I do to make it possible ???
libraries ???? what should I change in codes ???
sorry for that much question !!! 🙂

The reciever connections have 3 wires a signal, ground and voltage. I assume that only the signal wire is used because there are no servos. The electronic speed controller or throtle supplies the reciever with power and uses the signal wire to control the motor speed. On this the speed controllers are connected to the nano. Do I have to put the ground and voltage from one of the speed controllers to the reciever. I have spectrum 7 channel radio do I set it up as an airplane with no mixing

Hi i have a arduino uno with me . Want to know how different the code is from the one for arduino nano? Can we use the same code or do we have to make any changes?

i am new in audino, and when i upload the code to ATMEGA168 board, it keeps showing the wrong signal:
AeroQuad:203: error: ‘Motors_PWMtimer’ does not name a type
AeroQuad:216: error: ‘BatteryMonitor_AeroQuad’ does not name a type
AeroQuad.cpp: In function ‘void setup()’:
AeroQuad:506: error: ‘motors’ was not declared in this scope
AeroQuad:545: error: ‘batteryMonitor’ was not declared in this scope
AeroQuad.cpp: In function ‘void loop()’:
AeroQuad:775: error: ‘batteryMonitor’ was not declared in this scope
AeroQuad.cpp: In function ‘void readPilotCommands()’:
FlightCommand:33: error: ‘motors’ was not declared in this scope
FlightCommand:47: error: ‘motors’ was not declared in this scope
FlightCommand:64: error: ‘motors’ was not declared in this scope
AeroQuad.cpp: In function ‘void calculateFlightError()’:
FlightControl:29: error: ‘motors’ was not declared in this scope
FlightControl:36: error: ‘motors’ was not declared in this scope
AeroQuad.cpp: In function ‘void processCalibrateESC()’:
FlightControl:49: error: ‘motors’ was not declared in this scope
FlightControl:53: error: ‘motors’ was not declared in this scope
FlightControl:57: error: ‘motors’ was not declared in this scope
FlightControl:62: error: ‘motors’ was not declared in this scope
FlightControl:65: error: ‘motors’ was not declared in this scope
AeroQuad.cpp: In function ‘void processHeading()’:
FlightControl:130: error: ‘motors’ was not declared in this scope
AeroQuad.cpp: In function ‘void processMinMaxMotorCommand()’:
FlightControl:181: error: ‘motors’ was not declared in this scope
FlightControl:198: error: ‘motors’ was not declared in this scope
AeroQuad.cpp: In function ‘void processHardManuevers()’:
FlightControl:223: error: ‘motors’ was not declared in this scope
FlightControl:229: error: ‘motors’ was not declared in this scope
FlightControl:235: error: ‘motors’ was not declared in this scope
FlightControl:241: error: ‘motors’ was not declared in this scope
AeroQuad.cpp: In function ‘void processFlightControlXMode()’:
FlightControl:284: error: ‘motors’ was not declared in this scope
FlightControl:300: error: ‘motors’ was not declared in this scope
FlightControl:306: error: ‘motors’ was not declared in this scope
FlightControl:317: error: ‘motors’ was not declared in this scope
AeroQuad.cpp: In function ‘void readSerialCommand()’:
SerialCom:151: error: ‘motors’ was not declared in this scope
AeroQuad.cpp: In function ‘void sendSerialTelemetry()’:
SerialCom:350: error: ‘batteryMonitor’ was not declared in this scope
SerialCom:355: error: ‘motors’ was not declared in this scope
SerialCom:380: error: ‘motors’ was not declared in this scope
SerialCom:406: error: ‘motors’ was not declared in this scope

can u please help me,thanks

I am unsure how to wire the esc to the board, could I get some closer shots on how exactly the easc is wired to the receiver and nano?

hello I am a french teenager and I don’t understand how to install the software and the firmware on my arduino board..could you explain to me how I can do, because I would like to make a french “tutoriel” but if I can’t install the firmware..

sorry for the english mistake ,
on the waiting of an ansxer
bye !!

I want to make a quadcopter using brushed motor and arduino. Please mind high rpm brushed motor not brushless. Can you guide me whether it is feasible or not. If yes then what stuffs are required.

first of all awesome guide!!! kudos on that… i am using GY-80 instead of sparkfun 6DOF IMU but after i upload the flight control code to the nano and hook up the IMU the serial monitor says “Gyro not found” and the 3D quad in the configurator doesnt move at all. please could you help me out

That’s right because your IMU has another giro chip (L3G4200D) which is different form what sparkfun has (ITG-3200) , so what you need now, is to change the gyro address in the code and also some calibration parameters in order to make it work with your IMU .
I hope my explanation will help you.

You can use any IMU but you need to change the i2c addresses and some other parameters for sensor calibrations according to the new sensor chip on your IMU .
My suggestion to use sparkfun or any other IMU with the same giro and accelerometer chips that sparkfun use, in order to keep the code as it is.

Hey, I got that same one with a Kit and it works great, but havent much look with the AeroQuad, I will update if I do. Did anyone else have better luck?

Nice post, though by the number of posts it lacks in
detailed information. Why don’t you please revive
the post and write everything eligible and detailed,
so any beginner can follow.

Just a thought.

I am not able to push the code,I get a lot of errors about incorrect semicolons and how something isn’t a byte. help will be appreciated

Hello Russell. Once you have this set up constructed with the arduino nano and the software installed on it is it ready for flight? Or can you program it with the software in the above video that we downloaded to check orientation? Also can this then be used with the the aeroquad mission planner software that is shown in the scout build tutorial? Let me know. Thanks!

Charles I had the same issue until I went on to the archives of the arduino website and actually downloaded the arduino 0023 version. It’s an old version and it compiles perfectly on arguing 0023. The new versions will trigger several errors. Hope this helps. Try that.

It works great. I used nano and as it uses atmega 318 I got it perfectly .
thanks for the advice.

and newbie91 I can solve your problem.
If you are using an adruino micro then you have to specifically mention in the code.
you won’t need anything else just a perfect code on it .
otherwise its perfect.

Hi, I am wondering the firmware that I downloaded here contains only “.h” files only. But I do need a “.ino” file to run all the header files, right? Where can I get that and how am I suppose to do if I use Arduino UNO. Thanks.

Sir, would u give much brief details regarding the software u used..? How to put those software for flight controller into work??
And i also need the details of ESC and motors connection diagram..
I need ur urgent help!
Thank u.

u can mail me..

This is the first time ever I’m building a quad and for my university project. I’m thinking of not using the RC transmitter, instead, use zigbee etc to communicate and use a smartphone to control it (for visible and short ranges though).Anyone having done this or having any information or idea about this, please do help me.

i am using this for balancing my quadcopter bt there is a small amount of noise which makes it flicker about 0.5 degrees. any suggestions??

i am using this for balancing my quadcopter bt there is a small amount of noise which makes it flicker about 0.5 degrees. any suggestions???

can i use brushed motor with this projeck? the ouptut pwm conected to mosfet n mosfet cocected to motor ?

the output are conected to mosfet and to motor. did not unse esc brushed ?

Hi, i’m trying to load the code into my arduino uno, but when i check the sketch it gives me the error
” AeroQuad.h:23:22: fatal error: WProgram.h: No such file or directory “

I must say you have hi quality content here. Your posts should go viral.
You need initial boost only. How to get massive traffic?
Search for: Murgrabia’s tools go viral

I have noticed you don’t monetize your website, don’t waste your traffic, you can earn extra cash
every month because you’ve got high quality content.

If you want to know how to make extra $$$, search for: Boorfe’s tips best adsense

Leave a Reply

Your email address will not be published. Required fields are marked *