Yep, you got that right… that is why i added a second Arduino Uno, to control the strip.
So only the Mega have the “mobiflight firmware”. The Uno is just programmed using the Standard IDE to create a Sketch.
Only the Arduino Mega have connection to the sim, and the output from Mobiflight signals the Uno, when to turn on/off the light.
#include <Adafruit_NeoPixel.h>
// Definer pin and number of leds for two strips (Left and right)
#define LED_COUNT 30
#define LED_CABIN 5
#define LED_PINL 6
#define LED_PINR 7
#define INPUT_PIN1 8 // Define input pin 1 for Nav-light
#define INPUT_PIN2 9 // Define input pin 2 for Taxi light
#define INPUT_PIN3 10 // Define input pin 3 for Strobe light
#define INPUT_PIN4 11 // Define input pin 4 for Landing light
// Create NeoPixel-objects for both
Adafruit_NeoPixel StripL(LED_COUNT, LED_PINL, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel StripR(LED_COUNT, LED_PINR, NEO_GRB + NEO_KHZ800);
void setup() {
Serial.begin(9600);
StripL.begin(); // Init left NeoPixel-strip
StripR.begin(); // Init right NeoPixel-strip
StripL.show(); // turn off all LED on left strip
StripR.show(); // turn off all LED on right strip
StripL.setBrightness(50); // Set brightness on left strip (optional)
StripR.setBrightness(50); // Set brightness on right strip (optional)
pinMode(INPUT_PIN1, INPUT); // Define input pin 1 as input
pinMode(INPUT_PIN2, INPUT); // Define input pin 2 as input
pinMode(INPUT_PIN3, INPUT); // Define input pin 3 as input
pinMode(INPUT_PIN4, INPUT); // Define input pin 4 as input
}
void loop() {
static int prevInput1 = LOW;
static int prevInput2 = LOW;
static int prevInput3 = LOW;
static int prevInput4 = LOW;
int input1 = digitalRead(INPUT_PIN1);
int input2 = digitalRead(INPUT_PIN2);
int input3 = digitalRead(INPUT_PIN3);
int input4 = digitalRead(INPUT_PIN4);
if (digitalRead(INPUT_PIN1) == HIGH) {
// Turn on Nav-light
setNavLights();
} else {
// Turn off Nav-light
clearNavLights();
}
if (digitalRead(INPUT_PIN2) == HIGH) {
// Turn on Taxi light
setTaxiLights();
} else {
// Turn off Taxi light
clearTaxiLights();
}
if (digitalRead(INPUT_PIN3) == HIGH) {
strobeEffect(100); // turn onStrobe light
} else {
clearStrobeLights(); // turn off Strobe light
}
if (digitalRead(INPUT_PIN4) == HIGH) {
setLandingLights(); // turn on Landing light
} else {
clearLandingLights(); // turn off Landing light
}
}
void setNavLights() {
// Left strip (led 23-28) to red
for (int i = 23; i < 28; i++) {
StripL.setPixelColor(i, StripL.Color(255, 0, 0)); // Red light
}
// Right strip (led 23-28) to green
for (int i = 23; i < 28; i++) {
StripR.setPixelColor(i, StripR.Color(0, 255, 0)); // Green light
}
StripL.show();
StripR.show();
}
void clearNavLights() {
// turn off Nav-light
for (int i = 23; i < 28; i++) {
StripL.setPixelColor(i, StripL.Color(0, 0, 0)); // no light
StripR.setPixelColor(i, StripR.Color(0, 0, 0)); // no light
}
StripL.show();
StripR.show();
}
void setTaxiLights() {
// Middle 15 LED on both strips on, white
for (int i = 1; i < 15; i++) {
StripL.setPixelColor(i, StripL.Color(255, 255, 255)); // White light
StripR.setPixelColor(i, StripR.Color(255, 255, 255)); // White light
}
StripL.show();
StripR.show();
}
void clearTaxiLights() {
// Turn off taxi light
for (int i = 1; i < 15; i++) {
StripL.setPixelColor(i, StripL.Color(0, 0, 0)); // Sluk lys
StripR.setPixelColor(i, StripR.Color(0, 0, 0)); // Sluk lys
}
StripL.show();
StripR.show();
}
void setLandingLights() {
// Landing light on (Led 15 to 23)
for (int i = 15; i < 23; i++) {
StripL.setPixelColor(i, StripL.Color(255, 255, 255)); // White light
StripR.setPixelColor(i, StripR.Color(255, 255, 255)); // White light
}
StripL.show();
StripR.show();
}
void clearLandingLights() {
// Turn off Landing-light
for (int i = 15; i < 23; i++) {
StripL.setPixelColor(i, StripL.Color(0, 0, 0)); // No light
StripR.setPixelColor(i, StripR.Color(0, 0, 0)); // No light
}
StripL.show();
StripR.show();
}
void strobeEffect(int wait) {
int strobePattern[10] = {1, 0, 1, 0, 0, 0, 0, 0, 0, 0}; // Flash pattern
for (int j = 0; j < 10; j++) {
for (int i = 28; i < 30; i++) {
if (strobePattern[j] == 1) {
StripL.setPixelColor(i, StripL.Color(155, 155, 155)); // White light on led 28-30
StripR.setPixelColor(i, StripR.Color(155, 155, 155)); // White light on led 28-30
StripL.setPixelColor(0, StripL.Color(255, 79, 0)); // Orange light on led 0 (middle)
StripR.setPixelColor(0, StripR.Color(255, 79, 0)); // Orange light on led 0 (middle)
} else {
StripL.setPixelColor(i, StripL.Color(0, 0, 0)); // Light off
StripR.setPixelColor(i, StripR.Color(0, 0, 0)); // Light off
StripL.setPixelColor(0, StripR.Color(0, 0, 0)); // Light off
StripR.setPixelColor(0, StripR.Color(0, 0, 0)); // Light off
}
}
StripL.show();
StripR.show();
delay(wait);
}
}
void clearStrobeLights() {
// Sluk Strobe-light
for (int i = 0; i < 2; i++) {
StripL.setPixelColor(30 - i, StripL.Color(0, 0, 0)); // Light off
StripR.setPixelColor(i, StripR.Color(0, 0, 0)); // Light off
}
StripL.show();
StripR.show();
}