Adding External LED Indicators and a Piezo Beeper for Arm and GPS Status


I am using the APM 2 for both my quads and it is tricky to get the barometer covered to avoid errant airflow since it is below the daughterboard. To solve this, I ended up pretty much filling up my stack cover with breathable foam. But once that was done, I could barely see the on-board LED indicators.

Fortunately, the current code supports remote indicators without too much trouble.

If you look at the pin-out images on the Wiki, you will see that the AN pins are labeled Motor LEDs. They really don’t have a lot to do with the motors – but they do serve as pretty handy indicators.

If you look in the code, you will find defines for these pins as follows:

AN4 – Motor or Aux LED

AN5 – Motor or Beeper

AN6 – Motor or GPS

AN7 – Motor

AN8 – Motor

For my purposes, I focused on AN5 for the Beeper, AN6 for GPS indicator and AN7 as an Armed indicator.

The default seems to be to have the beeper enabled and the LEDs on. That is easy to change however. The different possibilities are set using bit masks to build the LED_mode parameter. A bit mask (if you already know, feel free to skip ahead) is simply a way of packing a bunch of on/off settings into one byte of data. A Byte is 8 bits, so you can have 8 different switches in one byte.  If you look at the following table, you will see a single bit is set to ‘1’ and the rest to ‘0’ in each row. To build the mask, you just add all the rows together and convert to a decimal number (or convert then add).

Bit Number

7              6              5              4              3              2              1              0

0              0              0              0              0              0              0              1      =      1              Motor LEDs On/Off

0              0              0              0              0              0              1              0      =      2              GPS On/Off

0              0              0              0              0              1              0              0      =      4              AUX Function On/Off

0              0              0              0              1              0              0              0      =      8              Beeper On/Off

0              0              0              1              0              0              0              0      =      16            Low Battery Flash – fast/slow

0              0              1              0              0              0              0              0      =      32            Motor LEDs NAV blink On/Off

0              1              0              0              0              0              0              0      =      64            GPS LEDs Nav Blink On/Off

1              0              0              0              0              0              0              0      =      128          Not used


Note that the NAV settings cause the LEDs (either the motor LEDs, the GPS LED, or both) to blink 3 times when you hit a waypoint in AUTO flight.

The low battery flashing defaults to fast flash so setting that bit to 1 will enable slow flash. 


I really only want the beeper, the GPS and the Motor LEDs on, so I set the mode to decimal value 11 (which is binary 00001011). This should equate to: GPS Nav blink off, Motor LED Nav blink off, low battery flash fast, beeper on, AUX off, GPS on, Motor LEDs on..


The way you set this to be the value used is through the Mission Planner.


Establish a connection with the APM and the Mission Planner software. Go to the parameters list and find LED_Mode. It should be set to something like 9. Change that to 170 (or whatever you decide to use) and write the settings to the APM.

The outputs on the APM are 5V, so for most LEDs, you’ll need a resistor on the positive lead (the longer leg of the LED). In my case, the blue LED I was using required a 100 Ohm resistor and the red one required a 150 Ohm resistor (note – not going to explain it here, but there are a ton of online resources and calculators to figure out the resistor values needed for a given LED). I soldered up the resistors and LEDs to leads and cemented them at the edge of my stack cover’s base. For the beeper, I just used a 5V piezo beeper I happened to have lying around. Radio shack sells one that will work, but it isn’t very loud. If you want volume, you may need to shop around,


When you connect to the AN outputs, you need to run the negative lead to the ground pin (the one nearest the edge of the board) and the positive lead goes to the signal pin (the one farthest from the edge of the board). The middle pin is always 5 Volts so if you plugged in there, the LED or beeper would be always on.


Beeper goes to AN5, GPS to AN6 and the ARMED light goes to any other motor LED output, but I chose to just use AN7.


That’s all there is to it. When you turn on the APM, you the LEDs will stay off until it is booted, then will flash the same as the on-board ones. When a GPS lock is achieved, the GPS LED will stay lit. When the bird is armed, the red LED will blink out and once it is fully armed, it will light a solid red. The beeper will beep twice on arming, and once on disarm.


Views: 108251

Comment by Marooned on November 29, 2012 at 9:09am

Comment by R_Lefebvre on November 14, 2012 at 5:42am

(...) I think Marooned started work on it recently but I don't know where he's at.

Here's the answer:

Comment by Simone Chiaretta on December 8, 2012 at 4:31pm

Is there implemented the feature that makes a LED (no idea which one) blinks when in acro/stable mode in different speeds? Like the video by jDrones?

Comment by Marooned on December 10, 2012 at 5:28am

Simone - this is on my todo list (check link in my previous comment). You can also buy jDrone IOBoard.

Comment by Søren Kuula on January 3, 2013 at 5:18pm

Hi, sorry about that with your finger -

- I have to preach a little for the idea that the armed but not running state should not exist.

  • It's dangerous on the ground, as seen
  • It's dangerous in the air (too little throttle and the motors will stall)

Some other copters run their motors in idle when armed, and they can't be stopped until disarmed. It is much better.



Comment by Craig Fraser on January 23, 2013 at 9:48am

And now with APM 2.9 it's screwed up, the remote ARM LED can't follow the APM's ARM LED, instead it's always flashing one way or another when enabled. Useless for me, I want it to solid when armed. These LEDs are my "telemetry" for now, I am pretty pissed off about this change actually, wish I knew the "logic" behind it...(unless of course it's just a mistake)

Comment by Andrew Chapman on January 23, 2013 at 9:10pm

Probably not the answer you're looking for, but it's very easy to override the LED handling in the source code, and it should be a safe thing to tinker with, even if you're not a very confident coder.

I was after a very specific behaviour and couldn't figure out the right logic using the built-in LED handling, so I just replaced the definition of 'update_copter_leds()' in the 'leds' file, compile, upload, works like a charm.

If anyone is interested, here's the code to have the lights off when disarmed, on only when armed AND with a GPS lock, and blinking when you hit the low battery level:

static void update_copter_leds(void)


    if (g.copter_leds_mode == 0) {

        copter_leds_reset();    //method of reintializing LED state


    int gpsgood = ((g_gps->status() == 2) && home_is_set); // GPS is on, and has position lock

    if (motors.armed() && gpsgood) {

        if (low_batt == true) {


        } else {

          // lights on

          copter_leds_off(); // off and on seem to be backward? bug?


    } else {

        // lights off

        copter_leds_on();  // off and on seem to be backward? bug?



BTW, I also needed to #define BATTERY_EVENT  ENABLED in APM_Config.h, otherwise the 'low_batt' was always false. Perhaps that's changed in 2.9 though, I'm running 2.8.1.

Comment by ziggy95 on January 27, 2013 at 11:46am


does it work with APM1 ?

Comment by iskess on February 4, 2013 at 6:39pm

Just what I was looking for.

Now I need to find some low draw LED's.


Comment by Craig Fraser on February 5, 2013 at 8:48pm

Thanks for the info Andrew. Forgot I had commented here.

I found out that for some reason, as long as my APM is connected via USB, the regular "motor LEDs" always fast-flash when armed. Even if the (fully charged) battery is connected at the same time. But they work properly if the USB is disconnected. I couldn't figure it out... I won't be flying with USB connected until I get a long extension, so it's OK I guess.

Comment by Martyn on March 29, 2013 at 3:51am
I can't find any mention of what a constant tone during flight means. I don't have the low battery warning enabled, could this be "ooh pretty satellites" aka GPS lock?


You need to be a member of DIY Drones to add comments!

Join DIY Drones

© 2019   Created by Chris Anderson.   Powered by

Badges  |  Report an Issue  |  Terms of Service