LEARN.PARALLAX.COM
Published on LEARN.PARALLAX.COM (https://learn.parallax.com)
Home > Running Lights for your ELEV-8 v3

Running Lights for your ELEV-8 v3

Are you ready to mod your ELEV-8 v3?  This tutorial will show you how to build a set of fully programmable running lights composed of bright RGB LEDs.  Completing this advanced tutorial will require custom PCBs, individual components from 3rd party vendors, and soldering equipment.  Although this tutorial requires surface-mount soldering, if you’ve never done any surface mount soldering before, this tutorial is easy enough to follow that you can succeed if you have a steady hand.

Running Lights - Materials

To build and install running lights for your ELEv-8 v3, you will need parts and supplies from several different sources.

 

Custom Printed Circuit Boards (PCBs)

The PCBs are available as a shared project from OSH Park, a community batch PCB service provider.  This PCB must be ordered in multiples of 3.  This means that in order to get 4—one for each boom—you will have to order 6 PCBs.  It may take approximately two weeks for your PCBs to be fabricated since they are made to order.

  • (6) Custom PCBs – https://oshpark.com/shared_projects/Ycc6C6G5

 

Soldering Supplies

The soldering techniques shown in this project make both traditional soldering with an iron, and also reflow soldering.  A syringe of low-temperature soldering paste makes it easy to surface-mount solder with a hobby-grade heat gun or a small electric frying pan.

  • (1) ChipQuick low-temp solder paste syringe – ChipQuick #SMDLTFP
  • A Heat Source and Heat-Proof Surface:
    • Heat Gun and a ceramic tile or old baking pan*  – OR –
    • Electric Frying Pan*
  • Soldering Iron or Kit – Parallax Basic Soldering Kit #700-10011
  • Solder
  • Protective Eyewear
  • Fine-point tweezers or needle-nosed pliers

*Once an electric frying pan, baking pan, pizza stone, or other kitchen utensil has been used for soldering, never use it for preparing food again! Solder and soldering paste can be hazardous to ingest.

 

Surface-Mount Electronic Components

To build the running lights, you will be soldering LEDs, capacitors, and voltage regulators to the PCBs.  The quantities shown are for 4 running lights.  To build up six running lights (2 spares), multiply each of the following quantities by 1.5:

  • (2) WS2812B raw LED 10 pack – Digi-Key #15251104-ND, or Adafruit #1665
  • (4) uA78M05 5V Voltage Regulator SOT-223 – Digi-Key #296-12290-1-ND
  • (12) 0.1 uF 0603 Ceramic Capacitors – Digi-Key #490-1542-1-ND
  • (4) 22 uF 0805 Ceramic Capacitors – Digi-Key #1276-2908-1-ND

 

Additional Hardware

To install the running lights, you will need some additional hardware, header pins, and cables:

  • (1) Saddle Washers 24-pack – Parallax #570-80061
  • (1) ELEV-8 v3 Hardware Pack – Parallax #570-80300
  • (1) 40-pin Single Row Header – Parallax #451-04001
  • (3) 24″ 3-Pin Signal-Power-Ground Cable Extension – Parallax #800-00240
  • (2) 16″ 3-Pin Signal-Power-Ground Cable Extension – Parallax #800-00160

 

Household Supplies

Finally, to aid in the assembly and install process, you will need:

  • Cotton swabs
  • Paper towels
  • Masking Tape
  • Permanent Marker

Solder the Surface Mount Parts

The first step in building running lights for the ELEV-8 v3 is to solder the surface-mount components to the printed circuit boards.  If you don’t know what to expect when reflow soldering, take time to watch some YouTube videos to understand how it works before proceeding.

 

Reflow Soldering Instructions

Make sure you have all of your materials laid out and ready in a well-ventilated area.  Avoid doing this over carpeted floors or other spaces where there may be a lot of static electricity.
  • First, put on your safety eyewear.
  • Lay out your boards on a hard, flat surface.  You will be using your syringe of ChipQuick to apply solder to the exposed pads on each PCB.  
  • Carefully squeeze a small amount of soldering paste onto each of the exposed pads as shown in the photograph below:

If you accidentally add too much soldering paste, wipe the excess away with a paper towel or cotton swab.  Do not try to wash the soldering paste away with water or cleaning solution.  It is okay if it is messy or smeared – simply leave the smudge for now, since it is much easier to remove after the PCBs have been reflowed later in this tutorial.

  • Next, use the tweezer or needle-nosed pliers to place each surface mount (SMD) component on the PCBs as shown in the photo below:  
  • The capacitors can be installed in either direction.  
  • The LEDs have a small notch in one corner that must be matched up with the triangle in the corner of the white printing on the PCBs – if you install them backwards the LED (and every LED after in the chain) will fail.
  • The voltage regulator can only be installed in one direction.

Once the SMD components have been placed on the PCBs, they are ready to be reflowed.  

 

If you are using an electric skillet:

  • Set the temperature to 350° F and let the skillet warm up.  
  • Using your tweezers or pliers, carefully set one of the PCBs on the skillet and wait for the solder to melt.  
  • Quickly check each component to make sure it is aligned properly before removing the board.  
  • If one of the components has slid away or moved, use your tweezers to nudge it back into place.  
  • Once the components are all in place, carefully remove the PCB and let it cool.  
  • Repeat this process for each PCB.

 

If you are using a heat gun:

  • Place the PCB on a surface that can be safely heated to 400° F such as a baking sheet over oven mits, a baking stone, or a ceramic tile.  
  • Hold the heat gun approximately one inch above the PCB and wait for the soldering paste to melt.  
  • Once solder in the area you are heating has melted, slowly move the heat gun across the board until all of the components have been soldered to the PCB.  
  • If any of the components have shifted or are not properly aligned, re-heat the solder until it melts and use your tweezers to nudge the component back into place.

Reminder! Once an electric frying pan, baking pan, pizza stone, or other kitchen utensil has been used for soldering, do not ever use it for preparing food again! Solder and soldering paste can be hazardous to ingest.

Solder the Through-Hole Parts

Before you proceed, use your masking tape and marker to label each board “1”, “2”, “3” and “4” to correspond with the ELEV-8 v3 boom that each PCB will eventually be installed on:

Next, you will be soldering the LED’s on the front edge of the PCBs.  Look carefully at the two pictures below.  The WS2812B LEDs have a triangular notch that marks pin 1.  

If you install the LEDs backwards, they (and any LED in the chain after one that is backwards) will fail, and potentially be damaged

To attach the LEDs to the front edge of the PCB:

  • Set an LED upside down with the notch facing away from you.
  • Hold the PCB vertically with the front facing toward you, and align the notch in the PCB over the LED.
  • Use your soldering iron to “tack” one of the LED’s pins to the PCB.
  • Repeat for the second LED.
  • Check to make sure the notch is in the right place on each LED by comparing it to the photographs above.  
  • If the LEDs are oriented correctly and aligned well, use your soldering iron to solder all 4 connections on the top of the PCB.
  • Flip the PCB over and solder the remaining 4 connections for the LEDs.

Next you will be installing the headers.

  • Use a pliers to break the 40-pin header into twelve 3-pin headers (you will have a few pins left over).
  • Set the PCB on top of two 3-pin headers.
  • Solder one of the header pins on each side.
  • Check to make sure they are aligned well.
  • Solder the remaining pins on the two 3-pin headers.

Finally, you will be solder-bridging the jumpers on the PCB.

Follow these instructions carefully.  Configuring these jumpers incorrectly could destroy the LED modules and your ELEV-8 v3 Flight Controller!

Your boards must be labeled 1, 2, 3 and 4 before proceeding.

  • On PCB 1, solder over to close the jumper labeled “Close on 1, 2, & 3” ONLY.

  • On PCB 2, solder over to close both jumpers.

  • On PCB 3, solder over to close both jumpers.
  • On PCB 4, solder over to close the jumper labeled “Close on 2, 3, & 4” ONLY. 

Test the Running Lights

Now you are ready to test your running lights.

Make sure that your work surface is clear of any metal including wire, tools, or hardware.  The Power Distribution Board, Running Light PCBs and Flight Controller all have exposed electrical connections that can easily short across exposed metal surfaces or objects.

  • Plug a 16″ 3-pin cable into the RGB port on the flight controller with the white wire up.
  • Plug the other end of the cable into the header marked “IN  RED  BLK” on the number 1 running light PCB, matching the colors on the wires to the labels on the board.
  • Plug a 24″ 3-pin cable into the header marked “OUT  RED  BLK” on the number 1 running light PCB, matching the colors on the wires to the labels on the board.
  • Plug the other end of the cable into the header marked “IN  RED  BLK” on the number 2 running light PCB, matching the colors on the wires to the labels on the board.
  • Plug a 24″ 3-pin cable into the header marked “OUT  RED  BLK” on the number 2 running light PCB, matching the colors on the wires to the labels on the board.
  • Plug the other end of the cable into the header marked “IN  RED  BLK” on the number 3 running light PCB, matching the colors on the wires to the labels on the board.
  • Plug a 24″ 3-pin cable into the header marked “OUT  RED  BLK” on the number 3 running light PCB, matching the colors on the wires to the labels on the board.
  • Plug the other end of the cable into the header marked “IN  RED  BLK” on the number 4 running light PCB, matching the colors on the wires to the labels on the board.
  • Plug a 16″ 3-pin cable into the header marked “OUT  RED  BLK” on the number 4 running light PCB, matching the colors on the wires to the labels on the board.
  • Plug the other end of the cable into one of the 3 pin headers on the ELEV-8 v3 Power Distribution Board.

Double check all of your connections, making sure that the correct PCBs are in the order shown.  Connecting the running light PCBs incorrectly can permanently damage the running lights and your Flight Controller!

  • Connect a battery to the ELEV-8 v3 Power Distribution Board.

Your running lights should all be glowing:

Edit the FC Firmware for LEDs

If you haven’t done so already, follow the directions here (/courses/elev-8-v3-quadcopter-assembly-guide/step-22-install-software) to download  the ELEV-8 v3 firmware using SimpleIDE.  Make sure you understand how to upload firmware to your ELEV-8 v3.  This project was tested with firmware version 1.0.2 and 1.0.3.

  • Follow the instructions in step 23 to find and open the Flight Controller Firmware.
  • With elev8-main.side open, click on the “Open Project Manager” icon in the lower left corner of the window:

A list of files will appear on the left side of the window.  

  • Click on elev8-main.h to open that file.
  • Scroll down until you you find the line
#define  LED_COUNT 2
  • Edit the line to say
#define  LED_COUNT 21

  • Next, click on the elev8-main.cpp file in the Project Manager Window.
  • In the elev8-main.cpp file, scroll down until you find the line (around line 135)
static long LEDModeColor;
  • After that line, add the following code:
static short RunningLightModeStep; //LED Running light mode setting and counter variables
static char RunningLightMode;
  • Next, scoll down until you find (around line 620)
UpdateFlightLEDColor();

//Test for flight mode change-----------------------------------------------
if( FlightEnabled == 0 )
{
  • Inside of that if statement (immediately after the code listed above), add the following code.  Pay close attention to the highlighted line.  If you add or take away running light modes, you will need to come back and modify this line.  If you have 4 modes, this line will say “RunningLightMode > 3” since the first mode is 0:
if( (Radio.Rudd < -750) && (-350 < Radio.Thro) && (Radio.Thro < 350) )  //is the left stick pushed straight to the left?
{
  if( (Radio.Aile > 750) && (-350 < Radio.Elev) && (Radio.Elev < 350) ) //is the right stick pushed straight to the right?
  {
    RunningLightModeStep++;               // add to the counter
    if (RunningLightModeStep >= 325)      // have the sticks been held there for 1.5 seconds?
    {
      RunningLightModeStep = 0;           // reset the counter
      RunningLightMode++;                 // increment to the next running light mode
      if (RunningLightMode > 1)  RunningLightMode = 0;   // This must be set for the number of different modes
      for( int i=0; i <= RunningLightMode; i++ )         // x short beep(s) to indicate the mode
      {
        BeepHz(4500, 100);
        waitcnt( CNT + 5000000 );
      }   
      loopTimer = CNT;                    // because the beeper overruns the main loop timer, it must be reset
    }
  }
}
  • Next, scroll all of the way to the bottom of the elev8-main.cpp code.
  • Inside the last function in the elev8-main.cpp code, delete or comment out this line of code:
for( int i=0; i<led_count; i++ )
  • Replace it with the following code:
  int idx = (LEDColorTable[FlightMode & 3] & LEDBrightMask) >> LEDBrightShift;   // get the color representing the current flight mode
    
  if(RunningLightMode == 0)   //Dim Running Lights
  {  
    LEDValue[0]  = Color;
    LEDValue[1]  = LEDValue[6]  = LEDValue[11] = LEDValue[16] = idx;
    LEDValue[2]  = LEDValue[3]  = LEDValue[4]  = LEDValue[5]  = LED_Green & LED_Quarter;
    LEDValue[7]  = LEDValue[8]  = LEDValue[9]  = LEDValue[10] = LED_Green & LED_Quarter;
    LEDValue[12] = LEDValue[13] = LEDValue[14] = LEDValue[15] = LED_Red & LED_Quarter;
    LEDValue[17] = LEDValue[18] = LEDValue[19] = LEDValue[20] = LED_Red & LED_Quarter;             
  } 

  if(RunningLightMode == 1)   //Standard Running Lights
  {  
    LEDValue[0]  = Color;
    LEDValue[1]  = LEDValue[6]  = LEDValue[11] = LEDValue[16] = idx;
    LEDValue[2]  = LEDValue[3]  = LEDValue[4]  = LEDValue[5]  = LED_Green;
    LEDValue[7]  = LEDValue[8]  = LEDValue[9]  = LEDValue[10] = LED_Green;
    LEDValue[12] = LEDValue[13] = LEDValue[14] = LEDValue[15] = LED_Red;
    LEDValue[17] = LEDValue[18] = LEDValue[19] = LEDValue[20] = LED_Red;           
  } 
  • Save your project.

DO NOT CONNECT YOUR ELEV-8’s Battery.  Make sure the propellers have been removed from your ELEV-8 quadcopter before continuing.

  • Plug your ELEV-8 v3 Flight Controller into your computer and select the corresponding port from the drop-down menu.
  • Click the Upload to EEPROM button.

Install the Running Lights

Now that your ELEV-8 Flight Controller has been updated with modified firmware for your LEDs, and you’ve tested them to make sure they work, you are ready to install the Running Light PCBs onto the booms underneath the motors. You will match each numbered PCB with the boom of the same number.

  • First, hold a saddle washer against the Running Light PCB as a reference and bend the pins slightly away from center as shown:

  • Repeat this for each PCB.
  • Start with the #1 boom on your ELEV-8 v3.  Unscrew and remove the locknuts and screws that are holding the motor mount to the boom.
  • Turn the landing gear away from the boom.
  • Hold the motor and mounting assembly against the boom to keep the Nylon spacers from falling out.
  • Look carefully at the diagram below.  You will need screws and Nylon spacers found in the ELEV-8 v3 hardware kit.  Replace the screws for the motor mount with the ones shown in the picture below:

  • Install the saddle washers and Nylon spacers.
  • Install the #1 Running Light PCB.

Make sure the Running Light that you numbered in a previous step matches the boom it is being installed on!  Failure to do so may permanently damage your Running Lights or Flight Controller!

  • Install the landing gear:

  • Install the Nylon locknuts and tighten them down.
  • Repeat this process for each of the remaining booms.

Saftey Test After Customizing

Now that you have modified the hardware and firmware for the ELEV-8 v3, it is necessary to test its functionality to make sure it is safe to fly. Yes, do this every time you made hardware and/or firmware modifications!

DO NOT SKIP THIS PROCEDURE!  Flying with untested firmware is dangerous and can cause severe injury or property damage or loss.

If you have not done so already, REMOVE YOUR PROPELLERS before proceeding!

If your ELEV-8 v3 fails to pass any of the steps below, STOP – disconnect the ELEV-8 v3’s battery and return to prior steps to begin troubleshooting the problem.

  • The propeller blades should NOT be installed on the motors. If they are installed, remove them now.
  • Place your ELEV-8 v3 on a hard, flat surface.
  • Turn on your transmitter.
  • Open the Parallax GroundStation on your computer.
  • Connect your ELEV-8 v3 to your computer with its USB cable.

Pay close attention to the RGB LED on the Flight Controller.  During this process, it should continue to flash/alternate colors.  Except during power-up, arming and disarming, if the LED stops flashing, there is a problem with your code and it is not safe to fly.

  • Verify that the GroundStation software shows that the ELEV-8 v3 is connected.
  • Pick up your ELEV-8 v3 and make sure that the GroundStation is displaying it’s orientation correctly and smoothly.
  • Move the sticks around on your transmitter and make sure that the GroundStation is displaying them properly.
  • Disconnect your ELEV-8 v3 from your computer.
  • Connect your ELEV-8 v3’s battery.
  • Arm your ELEV-8 v3.
  • Make sure all 4 motors are spinning.
  • Move your transmitter sticks around.  Continue moving them around for at least 90 seconds (1.5 minutes).  Make sure that your motors are changing speeds appropriately.

The Propeller microcontroller on the Flight Controller has a system clock that takes approximately 53 seconds to roll back over to zero and start again.  Testing for 90 seconds ensures that the rollover will not cause a lock-up.

  • Check your Gear switch to make sure that your ELEV-8 v3 is changing modes appropriately.
  • Disarm your ELEV-8 v3.  Make sure the motors stop.

If your ELEV-8 v3 passed all of the above tests, it should be safe to re-install the propeller blades when you are ready to fly.  

For your first flight with modified firware and hardware, follow all safety precautions.  
Fly gently, close to the ground, and away from any people, objects, or structures until you are confident that your ELEV-8 v3 is performing normally.

 

Install the Cables

Installing the 3-pin cables into the booms of your ELEV-8 v3 can be tricky.  It requires you to partially disassemble your ELEV-8 v3 and to work slowly and carefully as you feed cables through the booms.

It is possible to simply run the cables along the outside of the booms and zip-tie them.  If you choose to zip-tie the cables to the outside of your ELEV-8’s booms, simply connect them in the same manner as you did when you tested them in a prior step.

To install the cables inside of the booms:

  • Carefully lay out all 5 cables and label them as shown in the photograph below:

  • Pull the grommet out of each boom and slide it towards the motor:

  • Carefully pull the Flight Stack up and off of the four vibration dampers that attach it to the top chassis plate.  Leave the vibration dampers in the top chassis plate as shown in the photograph below:

  • Remove Boom #1 by removing the two screws that connect it to the chassis:

  • Push the end of the first 16-inch 3-pin cable marked “FC” into the cable hole by the motor on Boom #1 through the boom until it comes out of the other end.
  • Push the end of the first 24-inch 3-pin cable marked “2->” into the cable hole by the motor on Boom #1 through the boom until it comes out of the other end.
  • Re-install Boom #1.
  • Remove Boom #2 by removing the two screws that connect it to the chassis.
  • Bend up the end of the cable 24-inch 3-pin cable marked “2->” as shown the photograph below:

  • Push that cable end into the chassis-side of Boom #2.  Carefully watch into the hole where the motor wires enter to see when it reaches the motor end of the boom.
  • Reach in and pull out the end of the cable; you may need to use a needle-nosed pliers for this.

  • Push the end of the next 24-inch 3-pin cable marked “3->” into the cable hole by the motor on Boom #2 through the boom until it comes out of the other end.
  • Re-install Boom #2.
  • Remove Boom #3 by removing the two screws that connect it to the chassis.
  • Bend up the end of the cable 24-inch 3-pin cable marked “3->”.
  • Push that cable end into the chassis-side of Boom #3.  Carefully watch into the hole where the motor wires enter to see when it reaches the motor end of the boom.
  • Reach in and pull out the end of the cable; you may need to use a needle-nosed pliers for this.
  • Push the end of the next 24-inch 3-pin cable marked “4->” into the cable hole by the motor on Boom #3 through the boom until it comes out of the other end.
  • Re-install Boom #3.
  • Remove Boom #4 by removing the two screws that connect it to the chassis.
  • Bend up the end of the cable 24-inch 3-pin cable marked “4->”.
  • Push that cable end into the chassis-side of Boom #4.  Carefully watch into the hole where the motor wires enter to see when it reaches the motor end of the boom.
  • Reach in and pull out the end of the cable; you may need to use a needle-nosed pliers for this.
  • Push the end of the next 24-inch 3-pin cable marked “PDB” into the cable hole by the motor on Boom #4 through the boom until it comes out of the other end.
  • Re-install Boom #4.
  • Pull the end of the 3-pin cable marked “PDB” up through the center of the chassis as shown in the photograph below:

  • Connect the cable to one of the 3-pin headers on the Power Distribution Board as shown as the photograph below:

  • Reinstall the Flight Stack back on the vibration dampers.  Gentle use of needle-nose pliers can help with this, but be careful not to tear them.
  • Pull the ends of the cables through the grommet on each boom:

  • Re-install the grommets.
  • Carefully connect the 3-pin cables to the Running Lights.  Pay close attention to the labels on both the cables and the Running Light PCBs.  Match the wire colors and direction to the labels:

  • Once you have verified all of the connections and fully reassembled your ELEV-8 v3, remove the masking tape labels on the PCBs and cables.

Understand and Expand the Running Light Modes

The RGB (Red, Green, Blue) LEDs used in the Running Lights are WS2812B modules.  Each module contains a small microchip, a red LED, a green LED, and a blue LED:

Each module has only 4 connections: +5VDC, ground, an input, and an output.  The output of one WS2812B can be connected to the input of the next WS2812B.  You can chain hundreds of WS2812B modules together as long as you have enough power for the modules and a microcontroller fast enough to drive them.

The WS2812B modules look for a series of 24 bits.  The first 8 bits tell the module how bright its green LED will be lit.  The next 8 bits represent the brightness of the red LED, and the last 8 bits represent the brightness of the blue LED.  The bits are simply pulses.  When the WS2812B sees a pulse that is on for 0.35 µs and off for 0.8 µs, it interprets that as a 0 (zero), and when it sees a pulse that is on for 0.7 µs and off for 0.6 µs, it interprets that as a 1 (one).

When the WS2812B receives another 24 bits, it passes them on to the next WS2812B.  That module will see those 24 bits as its commands for setting its color.  Any additional commands will then be passed to the next WS2812B module:

The ELEV-8 v3 Flight Controller Firmware includes a driver that generates all of the necessary pulses to drive WS2812B LED modules, since there is a WS2812B right on the board.  All you have to do is edit the ELEV-8 v3 firmware to let the Flight Controller know how many LED modules are attached and what color each module should be.  So, one of the firmware modifications was to tell the Flight Controller how many LED modules are attached, by editing this line in the file elev8-main.h:

#define LED COUNT  2

…to read:

#define LED COUNT 21

That let the driver support the 20 Running Light LEDs (5 on each boom) plus the first one on the Flight Controller itself:

The function at the end of the elev8-main.cpp file named ALL_LED tells the driver what color to set each LED.  LEDValue[] is an array that holds values for each LED.  Setting the value of LEDValue[0] will set the color of the LED on the Flight controller itself.  LEDValue[1] will set the color of the first LED on the Running Lights (see the diagram above).

To set an LED to a specific color, assign a 24-bit value to the LEDValue array element.  For example, if you set LEDValue[1] = 0xFF0000, LED 1 will turn green:

This is very similar to the way web browsers set colors.  If you use an HTML color picker such as the one available at http://htmlcolorcodes.com/color-picker/ you can find the hexadecimal code for any color.  To make it work for the WS2812B LED modules, you have to switch the Red and Green bits.  HTML expects the bits to be in RRGGBB order, and the WS2812B expects them in GGRRBB order.

 

Try This

Here are some additional modes that can be added into the ALL_LED function at the end of the elev8-main.cpp file.  Remember to change the line earlier in the code to state the total number of functions.

CAUTION! Remember to always re-test your ELEV-8 to make sure it is safe to fly after making any firmware modifications!

  • Go back into the Flight Controller firmware and change the number highlighted in the mode below, to the number of modes you plan on adding:
    if( (Radio.Rudd < -750) && (-350 < Radio.Thro) && (Radio.Thro < 350) )
    {
      if( (Radio.Aile > 750) && (-350 < Radio.Elev) && (Radio.Elev < 350) )
      {
        RunningLightModeStep++;
        if (RunningLightModeStep >= 325) 
        {
          RunningLightModeStep = 0;
          RunningLightMode++;
          if (RunningLightMode > 4)  RunningLightMode = 0;   //This must be set for the number of different modes
          for( int i=0; i <= RunningLightMode; i++ ) 
          {
            BeepHz(4500, 100);
            waitcnt( CNT + 5000000 );
          }    
          loopTimer = CNT;
        }          
      }           
    }      
  • Copy and paste the modes below into the end of the ALL_LED function, which is at the end of elev8-main.cpp.

Stealth Mode – this turns off ALL of the LEDs including the one on the flight controller.

  if(RunningLightMode == 2)   //Stealth Mode
  {  
    for( int i=0; i<led_count; i++) LEDValue[i] = 0;
  }

Motor Response Mode – when armed, the color of each boom will change from green to red as the speed of its corresponding motor changes.  It is a very dim white when disarmed.

  if(RunningLightMode == 3)   //Motor Speed Visualization
  {  
    int mot1 = ((Motor[OUT_FL] << 8) - (Prefs.MinThrottle << 8)) / (Prefs.MaxThrottle - Prefs.MinThrottle);
    int mot2 = ((Motor[OUT_FR] << 8) - (Prefs.MinThrottle << 8)) / (Prefs.MaxThrottle - Prefs.MinThrottle);
    int mot3 = ((Motor[OUT_BR] << 8) - (Prefs.MinThrottle << 8)) / (Prefs.MaxThrottle - Prefs.MinThrottle);
    int mot4 = ((Motor[OUT_BL] << 8) - (Prefs.MinThrottle << 8)) / (Prefs.MaxThrottle - Prefs.MinThrottle);

    LEDValue[0]  = Color;
    
    if( FlightEnabled )
    {
      LEDValue[1]  = LEDValue[2]  = LEDValue[3]  = LEDValue[4]  = LEDValue[5]  = ((256 - mot1) << 16) | ((mot1 - 1) << 8);
      LEDValue[6]  = LEDValue[7]  = LEDValue[8]  = LEDValue[9]  = LEDValue[10] = ((256 - mot2) << 16) | ((mot2 - 1) << 8);
      LEDValue[11] = LEDValue[12] = LEDValue[13] = LEDValue[14] = LEDValue[15] = ((256 - mot3) << 16) | ((mot3 - 1) << 8);
      LEDValue[16] = LEDValue[17] = LEDValue[18] = LEDValue[19] = LEDValue[20] = ((256 - mot4) << 16) | ((mot4 - 1) << 8);
    } else
    {
      LEDValue[1]  = LEDValue[2]  = LEDValue[3]  = LEDValue[4]  = LEDValue[5]  = 0x040404;
      LEDValue[6]  = LEDValue[7]  = LEDValue[8]  = LEDValue[9]  = LEDValue[10] = 0x040404;
      LEDValue[11] = LEDValue[12] = LEDValue[13] = LEDValue[14] = LEDValue[15] = 0x040404;
      LEDValue[16] = LEDValue[17] = LEDValue[18] = LEDValue[19] = LEDValue[20] = 0x040404;  
    }                          
  } 

Police Lights Mode – Fun, but use this mode responsibly!

  if(RunningLightMode == 4)   //Police Lights         
  {  
    LEDValue[0] = Color;
    
    if( counter & 0b01000000 )         // use a bitmask on the system counter to create a longer delay
    {
      if ( counter & 0b00100000 )      // use a bitmask on the system counter to create a medium delay
      {
        if ( counter & 0b00001000 )    // use a bitmask on the system counter to create a short delay
        {
          LEDValue[1]  = LEDValue[2]  = LEDValue[3]  = LEDValue[4]  = LEDValue[5]  = LED_Blue;
          LEDValue[6]  = LEDValue[7]  = LEDValue[8]  = LEDValue[9]  = LEDValue[10] = 0;
          LEDValue[11] = LEDValue[12] = LEDValue[13] = LEDValue[14] = LEDValue[15] = 0;
          LEDValue[16] = LEDValue[17] = LEDValue[18] = LEDValue[19] = LEDValue[20] = 0;
        } else 
        {
          LEDValue[1]  = LEDValue[2]  = LEDValue[3]  = LEDValue[4]  = LEDValue[5]  = 0;
          LEDValue[6]  = LEDValue[7]  = LEDValue[8]  = LEDValue[9]  = LEDValue[10] = 0;
          LEDValue[11] = LEDValue[12] = LEDValue[13] = LEDValue[14] = LEDValue[15] = 0;
          LEDValue[16] = LEDValue[17] = LEDValue[18] = LEDValue[19] = LEDValue[20] = LED_Red;
        }                       
      } else 
      {
        if ( counter & 0b00010000 ) 
        {
          LEDValue[1]  = LEDValue[2]  = LEDValue[3]  = LEDValue[4]  = LEDValue[5]  = 0;
          LEDValue[6]  = LEDValue[7]  = LEDValue[8]  = LEDValue[9]  = LEDValue[10] = LED_Blue;
          LEDValue[11] = LEDValue[12] = LEDValue[13] = LEDValue[14] = LEDValue[15] = 0;
          LEDValue[16] = LEDValue[17] = LEDValue[18] = LEDValue[19] = LEDValue[20] = 0;
        } else 
        {
          LEDValue[1]  = LEDValue[2]  = LEDValue[3]  = LEDValue[4]  = LEDValue[5]  = 0;
          LEDValue[6]  = LEDValue[7]  = LEDValue[8]  = LEDValue[9]  = LEDValue[10] = 0;
          LEDValue[11] = LEDValue[12] = LEDValue[13] = LEDValue[14] = LEDValue[15] = LED_Red;
          LEDValue[16] = LEDValue[17] = LEDValue[18] = LEDValue[19] = LEDValue[20] = 0;
        }                               
      }               
    } else 
    {
      if ( counter & 0b00100000 ) 
      {
          LEDValue[1]  = LEDValue[2]  = LEDValue[3]  = LEDValue[4]  = LEDValue[5]  = 0;
          LEDValue[6]  = LEDValue[7]  = LEDValue[8]  = LEDValue[9]  = LEDValue[10] = LED_Blue;
          LEDValue[11] = LEDValue[12] = LEDValue[13] = LEDValue[14] = LEDValue[15] = LED_Red;
          LEDValue[16] = LEDValue[17] = LEDValue[18] = LEDValue[19] = LEDValue[20] = 0;
      } else 
      {
          LEDValue[1]  = LEDValue[2]  = LEDValue[3]  = LEDValue[4]  = LEDValue[5]  = LED_Blue;
          LEDValue[6]  = LEDValue[7]  = LEDValue[8]  = LEDValue[9]  = LEDValue[10] = 0;
          LEDValue[11] = LEDValue[12] = LEDValue[13] = LEDValue[14] = LEDValue[15] = 0;
          LEDValue[16] = LEDValue[17] = LEDValue[18] = LEDValue[19] = LEDValue[20] = LED_Red;
      }               
    }
  }

 

Your Turn

  • Use what you now know to create your own LED lighting pattern!

Using the Running Lights

The edits you made to your Flight Controller’s firmware to test the Running Lights provide two different modes for the running lights: Dim and Bright.  To switch between modes, you will use your transmitter’s sticks while the ELEV-8 v3 is disarmed.

To change Running Light modes, push and hold the sticks straight outward to the sides for at least 1.5 seconds:

The Flight Controller will beep a number of times indicating the mode.  It will cycle through all of the modes that are programmed into the firmware.

The code provided earlier in this tutorial sets the running lights as follows:

  • The two booms at the front of the ELEV-8 v3 are set to green
  • The two booms at the rear of the ELEV-8 v3 are set to red
  • The four innermost LEDs (one on each boom) represent the current flight mode.  When you change your ELEV-8 v3’s flight mode using the gear switch on your transmitter, these LEDs will change accordingly.

 

DISCUSSION FORUMS | PARALLAX INC. STORE

About | Terms of Use | Feedback: learn@parallax.com | Copyright©Parallax Inc. 2024


Source URL:https://learn.parallax.com/courses/running-lights-for-your-elev-8-v3/
Links