by Bits and Droids | 21-03-2023
Hi guys,
In this release, I've added 14 new variables. The release can be downloaded from the downloads page or at the bottom of this article.
Name | Function | Return value |
---|---|---|
Taxi light | getLightTaxiOn(); | bool |
Strobe light | getLightStrobeOn(); | bool |
Panel light | getLightPanelOn(); | bool |
Recognition lights | getLightRecognitionOn(); | bool |
Wing light | getLightWingOn(); | bool |
Logo light | getLightLogoOn(); | bool |
Cabin light | getLightCabinOn(); | bool |
Head light | getLightHeadOn(); | bool |
Brake light | getLightBrakeOn(); | bool |
Nav light | getLightNavOn(); | bool |
Beacon light | getLightBeaconOn(); | bool |
Landing light | getLightLandingOn(); | bool |
Stall warning | getStallWarningOn(); | bool |
Overspeed warning | getOverspeedWarningOn(); | bool |
The code used in my latest video is:
#include <BitsAndDroidsFlightConnector.h>
int ledA1 = 22;
int ledA2 = 23;
int ledA3 = 24;
int ledA4 = 25;
int ledB1 = 26;
int ledB2 = 27;
int ledB3 = 28;
int ledB4 = 29;
int buzzer = 50;
unsigned long startMillis;
unsigned long currentMillis;
const unsigned long period= 500;
void setup() {
pinMode(ledA1, OUTPUT);
pinMode(ledA2, OUTPUT);
pinMode(ledA3, OUTPUT);
pinMode(ledA4, OUTPUT);
pinMode(ledB1, OUTPUT);
pinMode(ledB2, OUTPUT);
pinMode(ledB3, OUTPUT);
pinMode(ledB4, OUTPUT);
pinMode(buzzer, OUTPUT);
//Set start milliseconds
startMillis = millis();
//serial for handling the incomming data
Serial.begin(115200);
Serial.setTimeout(15);
}
void loop() {
connector.dataHandling();
//Check the current mili secconds from start of the Arduino
currentMillis = millis();
if(connector.getStallWarningOn()){
if(currentMillis - startMillis >= period){
digitalWrite(ledA1, HIGH);
//Create the buzzer sound
tone(buzzer, 1200);
startMillis = currentMillis;
} else{
digitalWrite(ledA1, LOW);
noTone(buzzer);
}
}
//Create an alarm if overspeeding
if(connector.getOverspeedWarningOn()){
if(currentMillis - startMillis >= period){
digitalWrite(ledB1, HIGH);
//Create the buzzer sound
tone(buzzer, 1200);
startMillis = currentMillis();
} else{
digitalWrite(ledB1, LOW);
noTone(buzzer);
}
}
//if light is true
if(connector.getLightStrobeOn()){
digitalWrite(ledA2, HIGH);
}
//if light is false rinse and repeat for the other lights
if(!connector.getLightStrobeOn()){
digitalWrite(ledA2, LOW);
}
if(connector.getLightPanelOn()){
digitalWrite(ledA3, HIGH);
}
if(!connector.getLightPanelOn()){
digitalWrite(ledA3, LOW);
}
if(connector.getLightRecognitionOn()){
digitalWrite(ledA4, HIGH);
}
if(!connector.getLightRecognitionOn()){
digitalWrite(ledA4, LOW);
}
if(connector.getLightLogoOn()){
digitalWrite(ledB2, HIGH);
}
if(!connector.getLightLogoOn()){
digitalWrite(ledB2, LOW);
}
if(connector.getLightCabinOn()){
digitalWrite(ledB3, HIGH);
}
if(!connector.getLightCabinOn()){
digitalWrite(ledB3, LOW);
}
if(connector.getLightNavOn()){
digitalWrite(ledB4, HIGH);
}
if(!connector.getLightNavOn()){
digitalWrite(ledB4, LOW);
}
}