Read Inputs with the Flight Controller

The receiver and ESC pins on the Parallax Flight Controller can be used for a number of different purposes.  In addition to reading the signals coming in from the reciever and sending servo pulses to the ESCs, they can be driven high or low or be read as an input.

To read a pin, we will need to utilize 2 more of the functions, FCsetAsInput(); and FC_input(); we added to the Flight Controller firmware on the previous page:

FCsetAsInput( int pinNumber );
int pinState = FC_input( int pinNumber );

The first function, FCsetAsInput();, when used near the the beginning of the firmware's code, sets a pin to be an input.  The second function reads the pin, and its result can be placed in a variable to be used later.  The diagram below shows the pin numbers and names available in the firmware:

Try This

  • If you have not completed the last page, you must follow the instructions on that page first.
  • Using SimpleIDE, 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.cpp to make sure you are editing that file.
  • Find the following code that you added on the last page (near line 200):
// Set up the 3 pins attached to the LEDs as outputs
FCsetAsOutput(21);
FCsetAsOutput(22);
FCsetAsOutput(23);
  • Add these three lines to it:
FCsetAsInput(1);
FCsetAsInput(2);
FCsetAsInput(3);
  • Finally, find the code that you added after the line UpdateFlightLEDColor(); (near line 660).
  • Delete the changes you made in the previous page.
  • Add the following code:
  if( FC_input(1) == 1 )  // Check the P1 pin
  {
    FC_low(21);      // Turn the red LED on
  } else { 
    FC_high(21);     // Turn the red LED off
  }

  if( FC_input(2) == 1 )  // Check the P2 pin  
  {
    FC_low(22);      // Turn the left blue LED on
  } else {
    FC_high(22);     // Turn the left blue LED off
  }

  if( FC_input(3) == 1 )  // Check the P3 pin  
  {
    FC_high(23);     // Turn the left blue LED on
  } else {
    FC_low(23);      // Turn the left blue LED off
  }
  • 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.

  • Disconnect the 3 pin cables that connect Aux1, Aux2, and Aux3 between the Receiver and Flight Controller on your ELEV-8 v3, and save one of the cables for this activity.

  • Take the top cover plate off of your ELEV-8 v3 - this will allow you easily see the LEDs you are toggling and access different pins to connect the a spare 3-pin cable.
  • 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.
  • Look carefully at the diagram showing the side of the Flight Controller with the receiver connections and the video below.
  • Using a spare 3-pin cable, connect the white wire on the spare 3-pin cable to the middle pin and leave the red and black wires hanging to the side.
  • Use the other end of the 3-pin cable to jumper to the top pin, making connections to P1, P2, or P3:

When you make connections, the corresponding indicator LEDs on the Flight Controller board will turn on.