You can do more than just blink the LEDs attached to the ELEV-8 Flight Controller - you can connect the flight controller to an external LED, or even another development board like the Activity Board or an Arduino!
Although this part of the tutorial is optional, it is helpful to see how the flight controller can be programmed to control an external accessory such as a data-logging sensor.
Instead of turning on an LED on the Flight Controller itself, let's try turning on an external LED - this will demonstrate that the pins on the flight controller can be connected to external devices.
// Set up the 3 pins attached to the LEDs as outputs FCsetAsOutput(21); FCsetAsOutput(22); FCsetAsOutput(23); FCsetAsInput(1); FCsetAsInput(2); FCsetAsInput(3);
FCsetAsOutout( PIN_MOTOR_AUX1 );
if( Radio.Gear < -512 ) // Check the gear(mode) switch position { FC_low( PIN_MOTOR_AUX1 ); // Turn the external LED of } else { FC_high( PIN_MOTOR_AUX1 ); // Turn the external LED on }
DO NOT CONNECT YOUR ELEV-8's Battery. Make sure the propellers have been removed from your ELEV-8 quadcopter before continuing.
If you wish to connect another development board such as an Activity Board or an Arduino to your ELEV-8 v3, you will need a way to power that board.
Although this example is specific to an Activity Board, the same concepts can be used to connect and Arduino or even a BASIC Stamp development board.
In this example of two-way communication, when the gear (mode) switch is flipped on, the Flight Controller sets one of its pins high. This pin, which is connected to an Activity Board, tells the Activity Board to begin its program. The Activity Board then turns on 3 LEDs in 3 seconds. Then, the Activity Board sets one of its pins, which is connected back to the Flight Controller, high. When the Flight Controller detects that that pin is high, it turns on one of its on-board LEDs.
This application is especially useful because the Activity Board has an SD card slot and is able to do data-logging with any sensor that you are able to attach to it. Click here for a tutorial on using the Activity Board to record data to an SD card. [1]
// Set up the 3 pins attached to the LEDs as outputs FCsetAsOutput(23); FCsetAsOutput(PIN_MOTOR_AUX1); FCsetAsInput(PIN_MOTOR_AUX2);
if( Radio.Gear < -512 ) // Check the gear(mode) switch position { FC_low( PIN_MOTOR_AUX1 ); // Turn off the Activity Board trigger } else { FC_high( PIN_MOTOR_AUX1 ); // Turn on the Activity Board trigger } if( FC_input(PIN_MOTOR_AUX2) == 1 ) // Check if the Activity Board is sending a signal { FC_low(23); // Turn on the on-board LED } else { FC_high(23); // Turn off the on-board LED }
DO NOT CONNECT YOUR ELEV-8's Battery. Make sure the propellers have been removed from your ELEV-8 quadcopter before continuing.
#include "simpletools.h" // Include simple tools int main() // Main function { // Add startup code here. while(1) { low(26); // make sure all LEDs low(27); // and the Flight Controller low(3); // trigger are off low(10); if(input(11) == 1) // Did the flight controller send { // a high signal? high(26); // Turn on the first LED pause(1000); // Wait 1 second high(27); // Turn on the second LED pause(1000); // Wait 1 second high(3); // Turn on the third LED pause(1000); // Wait 1 second high(10); // Send a signal to the Flight Controller while(input(11) == 1); // Wait until the Flight Controller stops } // sending a high signal } }
Links
[1] http://learn.parallax.com/propeller-c-simple-devices/sd-card-data