// ALGMS_basic demonstration // Use at your own risk // // This version of the Amphibian Landing Gear Monitoring System code // updates the Water, Land, and Flap lights based only on // combinational logic, and is meant as a simple example of how // an Arduino could be used to update status lights based on // various sensors. // // This version DOES NOT not implement any of the flashing states or // the voice output module. It also does not catch any ERROR conditions. // // Note: the logic levels may be inverted depending on the sensors/lights used. // // Define which pins each of the inputs and outputs are connected to. // In this case. it doesn't matter which pins are used for each // function, as long as the definitions below match the physical connections! // Pin mappings for the output pins static int pinWaterLight = 2; static int pinLandLight = 3; static int pinFlapsDwnLight = 4; static int pinVoice1 = 5; static int pinVoice2 = 6; static int pinVoice3 = 7; static int pinVoice4 = 8; static int pinVoice5 = 9; static int pinVoice6 = 10; static int pinAudioEnable = 11; // Pin mappings for input signals static int pinLowAirspeed = 13; static int pinPortGearUp = A0; static int pinPortGearDwn = A1; static int pinStbdGearUp = A2; static int pinStbdGearDwn = A3; static int pinGearUpCmd = A4; static int pinFlapsDwn = A5; // define state of inputs and outputs static int gearAtLimit = HIGH; static int flapsDown = HIGH; static int lightOn = LOW; // pin drives cathode low to turn on static int lightOff = HIGH; // this function is called once when the Arduino is booted up to initialize // the Arduino input and output pins and any software variables. void setup() { // Set Lights to Output pinMode( pinWaterLight, OUTPUT ); pinMode( pinLandLight, OUTPUT ); pinMode( pinFlapsDwnLight, OUTPUT ); // Set voice pins to output, LOW digitalWrite( pinVoice1, LOW ); pinMode( pinVoice1, OUTPUT ); digitalWrite( pinVoice2, LOW ); pinMode( pinVoice2, OUTPUT ); digitalWrite( pinVoice3, LOW ); pinMode( pinVoice3, OUTPUT ); digitalWrite( pinVoice4, LOW ); pinMode( pinVoice4, OUTPUT ); digitalWrite( pinVoice5, LOW ); pinMode( pinVoice5, OUTPUT ); digitalWrite( pinVoice6, LOW ); pinMode( pinVoice6, OUTPUT ); // Set input pins to input pinMode( pinLowAirspeed, INPUT ); pinMode( pinPortGearUp, INPUT ); pinMode( pinPortGearDwn, INPUT ); pinMode( pinStbdGearUp, INPUT ); pinMode( pinStbdGearDwn, INPUT ); pinMode( pinGearUpCmd, INPUT ); pinMode( pinFlapsDwn, INPUT ); } // The loop function is called repeatedly...put logic here void loop() { // Set the state of the Water light based on the 2 Gear Up inputs if( digitalRead( pinPortGearUp ) == gearAtLimit && digitalRead( pinStbdGearUp ) == gearAtLimit ) { digitalWrite( pinWaterLight, lightOn ); } else { digitalWrite( pinWaterLight, lightOff ); } // Set the state of the Land light based on the 2 Gear Down inputs if( digitalRead( pinPortGearDwn ) == gearAtLimit && digitalRead( pinStbdGearDwn )== gearAtLimit ) { digitalWrite( pinLandLight, lightOn ); } else { digitalWrite( pinLandLight, lightOff ); } // Set the state of the FlapDown LED based on the state of the FlapsDwn input if( digitalRead( pinFlapsDwn ) == flapsDown ) { digitalWrite( pinFlapsDwnLight, lightOn ); } else { digitalWrite( pinFlapsDwnLight, lightOff ); } }