Arduino Project – Gyro Based RC Controller

Arduino Project – Gyro Based RC Controller

I’ve started work on a new project – a Gyro Based RC controller using an Arduino Uno as the microcontroller – for use on my RC planes and multirotors (maybe even cars at some point).  But for now I’m developing the software using this board:


Arduino RC Controller


The components I’m using are:

Arduino Uno – Basic Arduino Card (normal form factor)
Sain Smart Servo Shield – Shield which is useful for RC modellers to connect their radio and servos to
OrangeRX 6 Channel Receiver
– OrangeRX 6 channel receiver
Gyro breakout card – I made my own which you can read about here, but you could also use the SparkFun one

Right now I’m still getting my feet wet with Arduino, but have been able to do a number of useful things with it.

To date I’ve been able to read the values out of the gyro using the I2C bus – here is what the raw data looks like:

Basically this shows the raw values coming out of the gyro.  Every least significant bit represents 1/14.375 degrees per second (which means 14 means the Tricopter is turning about one degree per second in a particular axis).  The other characteristic of this gyro is that the rate drifts which temperature and that is why they’ve build in a temperature sensor into the chip.  If you want to learn more about these chips you can find it on the Invensense website.

Introduction to Processing

Once I had all of this I wanted to visual the data better.  I considered doing this in Visual C++, but frankly got discouraged with all of the object classes which were involved in setting up the even most simple GUI.  Not at all for the casual user.  As I’ve been learning more about the Arduino – maybe of the texts mentioned the “Processing” environment.  After looking at a few example I saw how easy it was to write graphical program with very little knowledge of new libraries.  If I wanted to make a line – I use the command:

line (x1, y1, x2, y2)”

and that is it!  Also, interfacing to the Arduino was just as easy, and used a format very similar to the format used by the Arduino.  For example, to open the serial port I would just do:

myPort = new Serial(this, Serial.list()[portIndex], 9600);

So, after about an hour or so of coding up a simple GUI – I had my Arduino successfully talking to Processing (on my Mac) and I was able to see the effect of waiving the little micro controller around in real time.  Really neat!

You can really see from the graph when I moved the board slowly, and when it was moved abruptly.

Interfacing to the OrangeRX Receiver

The next piece of work I’ve done is in terms of interfacing to the OrangeRX Receiver.  For those of you who don’t know – an RC receiver “talks” to the servo but sending a short pulse over and over again..  The length of the pulse determines the position of the servo:

The first column show the position of the throttle and I moved it from 0 up to about 3/4s – and you can see the numbers (which represent microseconds – 1 millionth of a second) go from about 960 -> 1693..  All happening in real time…

Next – Installing the Controller onto the Tricopter

I’ve been having great success with the Tricopter and I recommend building it to anybody interested in getting started with multi-rotors.  For me it is also serving as an excellent platform for the controller development.  Here’s the Tricopter with the controller installed:

Arduino Installed on RCExplorer Tricopter

Arduino Installed on RCExplorer Tricopter


And from a winder angle:

Arduino Installed on RCExplorer Tricopter - Wide Angle

Fits very nicely on top of the standard base plate.

About the Controller

The Controller will be a PID based controller which stands for, and if you’d like to know more about the PID controller I suggest you check the paper on this website:

PID without PhD

Initially I have coded up just the “P” component of the controller (which is the proportional control).  This works to counter act the current about of rotational turn of the Tri.

I plan to describe the controller at a later time, but now you’re going to have to trust me…  ;-)

First Flights…

Here – a picture is worth a thousand word, so here’s a video describing it all:

I hope you are enjoying this thread and I’d like to continue developing it..  Comments are very welcome.




50 Responses to Arduino Project – Gyro Based RC Controller

  1. Pingback: Happy Birthday (and start of new Arduino project) | ILoveFPV.COM

  2. Stephen Boyd says:

    excellent project. I just went a hunted through my robotics box and found just about all the bit’s I’ll need to duplicate what you’ve done. I also found a set of paired Xbees that can say bye bye to the serial cable.


    • Steve says:

      I’m very interested in the XBees and the like… It’s a natural for us doing RC work… That will have to be a follow on project for me. Which XBees do you have?

      • Stephen Boyd says:

        I have the 900mhz long range set for my Drone that I’m working on. Here’s the link for it…
        It’s in my APM2 autopilot rock crawler ready for some decent weather to give it it’s first test run. The Xbee will be used to return the data for the OSD back at the base laptop. Being virtually plug and play, the xbees can be swapped from one project to another, aint technology great :)


        • Steve says:

          Looks good – have you range checked it? 6miles per the website has some pretty interesting opportunities… ;-)

          • Stephen Boyd says:

            I like the ability to reprogram the arduino during it’s little wander around. The range is actually low compared to some of the higher power ones. I’ve seen ranges of 50+ MILES stated. This means high altitude data transfer for balloons or some serious long range control/data linkage.
            I haven’t tried mine yet but it’s sitting next to the desk patiently waiting.

            clear skies

    • Swoop_G says:

      Stephen, are you from Houston by any chance?

  3. Andre Elb says:

    Cool! I like that you’ve started with the harder Arduino stuff now :)

    • Steve says:

      What do you mean by harder? ;-)

      I think the website needs to differentiate itself from other RC sites – this is one of the ways I’m hoping to do this.

      • colorex says:

        Had not seen the video before… So do you have pots in place to adjust gains, or do you have to modify the firmware and reflash it?

        • Steve says:

          Right now it has to be done by modifying the firmware. I’m looking into some ideas to be able to do this easier at the field…

  4. Guy says:

    this is a cool project !

    subscribed ..

  5. Steve says:

    Thanks Guy! I’ll post move over the weekend on it…

  6. Lenz Grimmer says:

    If you want to spare yourself some time, consider using the MultiWii code base for this. It already supports all the components you are using:

  7. Pingback: The Arduino based Multi-Rotor controller | ILoveFPV.COM

  8. Pingback: Arduino Tricopter Controller and First Flights (new video) | ILoveFPV.COM

  9. cwozny says:

    I work on these types of systems for a living and I’m just curious: are you only using a gyro for your attitude estimation? Even with calculating the gyro bias with the temperature, small errors will add up VERY quickly. Vibrations will also throw off the gyro bias making the bias estimation useless. I suggest utilizing a 3-axis accelerometer as well for calculating your attitude (and maybe a magnetometer if you want heading correct as well.)

    • Steve says:

      Hi Cwozny,

      Thanks for your question and comment – I’ve been waiting for a question like this.. ;-)

      Yes – I know about the gyro bias vs. temperature issue. We’ve actually done some characterization on this and frankly they coorrelate very well. At this point though I’m just doing a fairly long term average of the bias (5 seconds on startup) and subtracting that out of the real time data. The flight time is 10+ minutes, and don’t think the temp would fluctuate too much over this time. Of course if I am going to sail her up to 10000ft I’d definitely need to look into this… ;-)

      This isn’t for attitude estimation – it is more for rate stabilization at this point. i.e. make it just flyable. The early Tri which this was based on used simple rate gyros – and effectively I’m modeling this in software (see v1 Tricopter for details)

      However I do want to go where you are suggesting next. The ITG3200 looks to be pin compatible with the MPU-6050 which I think I’ll incorporate to my next multi build/controller. Do you have any experience with this? Haden’t though about the magnetometer as well – I was hoping the PI controller would neutral out any long term error, but I guess the ultimate for this is the magnetometer…

      Appreciate the comment…


      • cwozny says:


        For research in our universities’ MAV lab, we use the Paparazzi Lisa/M autopilot ( which has a 9dof IMU. It uses the MPU-6000 for gyro/accel and the HMC5883 magnetometer for a full blown AHRS. Invensense came out with a new chip earlier this year: the MPU-9150 which has all three sensors on one chip ( It even estimates its attitude and heading on the chip itself. I’m not sure how readily available it is, but I’d love to get my hands on it and try it. I believe there is already Arduino code based on this chip.

        – Chris

        • Steve says:

          Hi Chris,

          Very interesting… I’ve actually been looking at the ARM M3 as the processor for my next gen controller. NXP have a breakout board using the LPC1769 there LPCEXPRESSO platform: This also an M3 processor and looked quite interesting to me. It’s 10X the speed, 32bit processor, with all the whistles and bells in terms of timers, UARTs, I2C, SPI, etc. Great support in terms of IDE, C compilers, JTAG debug… I’ll have to take a another look at Lisa/M. Are these available from somewhere? Or do you have to build yourself?

          My background includes fixed point DSP firmware development, and frankly gets me frustrated with the Atmega328 processor… I guess great for Arduinos – where Artists and hobby people and put them into projects, but old and slow in my opinion for real time work..

          What kind of research are you doing in your lab with this?


    • Steve says:


      Could you suggest a few good papers on calculating attitude with gyro + accelerometer? I’m doing a search on IEEE, and there are so many….


      • cwozny says:


        There are many simple ways to do that using a Kalman filter, but most implementations are for rotorcraft or non-flying vehicles which means they don’t have to worry about centripetal acceleration due to turning which makes a big difference.

        I don’t have all of my documents in front of me, but this looks like a pretty solid article for explaining sensor fusion via Kalman filtering:

        – Chris

        • Steve says:

          Chris – I’ve been working on a new article on the Kalman filter for the site. Here’s a draft of where I am, but I’ve still got some questions lingering. Take a look and let me know what you think…

          I’ve got a 2D example of the Kalman in the works, but I am still debugging this. It is hard to find a clear and practical example of the Kalman (or maybe my linear algebra is too rusty for my own understanding)..


  10. cwozny says:

    You can get it here:

    We work on fixed-wing VTOL MAVs which have a 6″ wingspan at the University of Arizona.

    • Steve says:

      Question for you – what is the research using these days for scientific computing? I’ve mostly used Matlab in the past, but no longer have a license… Scilab and Octave are slightly promising, but in practice seem like buggy bloatware…

      Downloaded Python with NumPy and SciPy – and am really enjoying these!

      I’ve got some modelling I need to do of my tri/quad, so that’s why I’m asking…

      • cwozny says:

        I use MATLAB almost exclusively. I’m pretty sure Octave is completely compatible with all MATLAB code except for maybe some of the hardcore toolboxes. Why do you say it’s bloatware?

        I’ve heard good things about SciPy and NumPy as well as alternatives to MATLAB.

  11. Steve says:

    I’d probably use Matlab if I was in a University environment or had some other access to a license..

    Actually – I’ve just spent some time with Python and SciPy/NumPy and am very impressed! It will be my next posting on the forum showing the Kalman filter implemented in Python… It has some quirks to get over if you are a Matlab user, but really isn’t too bad of a learning curve…

  12. Alexname says:

    Hello Steve,
    Can you help me? Can you show simple of code how you get value from OrangeRX Receiver on Arduino UNO?

  13. Steve says:

    Hi Alex – sorry, didn’t get it posted last night as I got in late. I’ll try to post tonight.

    Lenz – I had some difficulty with the stock Arduino servo code. Worked OK for one servo, but when trying to coordinate 4 they started to glitch. I reviewed the MultiWii code and they seemed to have the same problem requiring them to median filter the inputs..

    I did some up with my own scheme which I’ll be happy to share..

  14. Steve says:

    Alex – here’s how I did it…. Hope this helps… -Steve

    timeNow = TCNT1;
    portb_Now = PINB;
    int PulseLength_tmp;
    int edgeCount;

    // Check for rising edge
    if (!(portb_Last & 1< > 1;
    if (PulseLength_tmp > 900 && PulseLength_tmp < 2200) pulseLength[edgeCount] = PulseLength_tmp; } } portb_Last = portb_Now; }

  15. Steve says:

    Alex – you also need this in you setup:

    // Enable PC Change Interrupt for digital pins 8,9,10,11

    Good luck sir...

  16. xozip! says:

    Hi! im doing the project, a tricopter using arduino & gyro and i can’t figure out how i can use the angular rate to stabilize the copter. Sorry for being ignorant, Can you share to me your arduino sketch? Here is my email:, thanx.

  17. Juan says:

    Hello, how do you read the orangeRX? In your code there is only the interrupt of PCINT0 and where is the other (1,2 and 3)? And hoe do you sincrhonized them?

    you use a simple timer divider of 1 for the gyro, ¿why? I have used a valor of cero, then you will have a simple of 8Khz.

    I am working in a Project of an adaptive quadcopter you can see it in



  18. Steve says:

    Hi Juan,

    The OrangeRX inputs are just measured for time high. A change on any of the inputs triggers the interrupt – then you just have to decode which one toggled.

    I tried using the stock PulseIn command, but the inputs twitched when I did that so I needed to use this approach.

    As for the timer divider – I see your point. I don’t think it is critical for this application as I only monitor the gyro sample every 20ms.. Perhaps this is more for applications which generate an interrupt off the gyro.

    Your project looks really cool (just wish it was in English)..



  19. Juan says:

    Hello, you tricopter is amazing. However i have some question.

    – I have seen the signal receivers OrangeRX in an osciloscope and i.e. channel 1 and channel 2 are overlapping, i say they start rise edge in the same time. Then How you can discriminate in the PCINTO interrupt.

    – Regarding attitude, you only calculate it with giro, but if the tricopter turn 180 grades, what happens?


  20. Steve says:


    It doesn’t matter if they occur at the same time – there will be just one interrupt (and this routine can process two edges within one interrupt event).

    If it flips 180? It doesn’t matter either – this is just a rate dampening process. But if it is upside-down it will crash soon! ;-)

    Thanks for your comment!


Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>