/*B.O.M
Arduino Uno
White Led Vf 3.2v If 20mA 1000mcd
100ohm resistor
*/
const byte Led1 = 2; // Always on. May add more at some point for fiber optics
const byte strobe1 = 3; // Strobe light. Not sure if gonna use usee yet
const byte nav1[] = {4,7}; //Navigation lights. May copy for use in cockpit and hold lighting
unsigned long strobeOnTime = 20;
unsigned long strobeOffTime = 2000;
unsigned long navTime = 1000;
void setup() {
// put your setup code here, to run once:
pinMode(Led1, OUTPUT);
pinMode(strobe1, OUTPUT);
pinMode(nav1[0], OUTPUT);
pinMode(nav1[1], OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
strobe();
nav();
alwayson();
}
void alwayson() {
// put your main code here, to run repeatedly:
strobe();
digitalWrite(Led1, HIGH);
}
void strobe()
{
static bool state = 0;
static unsigned long timer = 0;
static unsigned long interval = strobeOffTime;
if (millis() - timer >= interval)
{
timer = millis();
if (state == HIGH)
{
digitalWrite(strobe1, HIGH);
interval = strobeOnTime;
}
else
{
digitalWrite(strobe1, LOW);
interval = strobeOffTime;
}
state = !state;
}
}
void nav()
{
static bool state = 0;
static unsigned long timer = 0;
unsigned long interval = navTime;
if (millis() - timer >= interval)
{
timer = millis();
state = !state;
digitalWrite(nav1[0], state);
digitalWrite(nav1[1], !state);
}
}