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:
A list of files will appear on the left side of the window.
// Set up the 3 pins attached to the LEDs as outputs FCsetAsOutput(21); FCsetAsOutput(22); FCsetAsOutput(23);
FCsetAsInput(1); FCsetAsInput(2); FCsetAsInput(3);
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 }
DO NOT CONNECT YOUR ELEV-8's Battery. Make sure the propellers have been removed from your ELEV-8 quadcopter before continuing.
When you make connections, the corresponding indicator LEDs on the Flight Controller board will turn on.