Ausgehend vom Sketch in #0 habe ich den lichtempfindlichen Widerstand ergänzt:
// http://forum.arduino.cc/index.php?topic=395411.msg2721251#msg2721251
// Lichtsteuerung Modellflugzeug (Standmodell)
// Programm zur Lichtsteuerung Flugzeug
// Programme:
// 0 - Cold and Dark
// 1 - Day: NAV
// 2 - Day: NAV/Beacon
// 3 - Day: NAV/Beacon/Taxi
// 4 - Day: NAV/Beacon/Taxi/Landing/Strobes
// 5 - Night: NAV/Logo/Innenbeleuchtung
// 6 - Night: NAV/Logo/Innenbeleuchtung/Beacon
// 7 - Night: NAV/Logo/Innenbeleuchtung/Beacon/Taxi
// 8 - Night: NAV/Logo/Innenbeleuchtung/Beacon/Taxi/Landing/Strobes
// Lampenauflistung:
// Bezeichnung Farbe Position I/O bei Programm Pin
// 0 1 2 3 4 5 6 7 8
// --------------------------------------------------------------------------------------------------------------------------------------
// 1 - NavLicht rot blended winglet - left O I I I I I I I I 2
// 2 - NavLicht grün blended winglet - right O I I I I I I I I 2
// 3 - NavLicht weiß blended winglet - left O O I I I O I I I 3
// 4 - NavLicht weiß blended winglet - right O O I I I O I I I 3
// 5 - NavLicht weiß APU exhaust door O O I I I O I I I 3
// 6 - NavLicht weiß body - left O O O O O O I I I 4
// 7 - NavLicht weiß body - right O O O O O O I I I 4
// 8 - Innenbeleuchtung weiß Cabin O O O O O I I I I 5
// 9 - LogoLicht weiß elevator - left O O O O O I I I I 6
// 10 - LogoLicht weiß elevator - right O O O O O I I I I 6
// 11 - rotating Beacon rot body - up O O I I I O I I I 7
// 12 - rotating Beacon rot body - down O O I I I O I I I 7
// 13 - Taxischeinwerfer weiß front gear O O O I I O O I I 8
// 14 - Taxischeinwerfer weiß main gear left O O O I I O O I I 8
// 15 - Taxischeinwerfer weiß main gear right O O O I I O O I I 8
// 16 - Landescheinwerfer weiß wing - left O O O O I O O O I 9
// 17 - Landescheinwerfer weiß wing - right O O O O I O O O I 9
// 18 - Strobe weiß blended winglet - left O O O O I O O O I 10
// 19 - Strobe weiß blended winglet - right O O O O I O O O I 10
const byte LED_AUSGAENGE[] = { 2, 3, 4, 5, 6, 7, 8, 9, 10}, taster = A0, blitzLed = 8, blitzLed2 = 5;
const byte eingang = A1; // lichtempfindlicher Widerstand
bool aktTaster, altTaster, blitz, blitz2;
#define TagNachtOffset 4
#define SCHWELLE 512 // Schwelle Tag/Nacht
byte prgNr; // aktuelles Programm
int sensorWert;
const unsigned int blitzZeiten[] = {110, 1100, 110, 1100}; // {50, 50, 50, 400}; Airbus Rotating Beacon {110, 1100, 110, 1100}; Boeing Rotating Beacon
const byte anzahlBlitzZeiten = sizeof(blitzZeiten) / sizeof(blitzZeiten[0]);
byte blitzZeitenNr;
unsigned long aktMillis, blitzMillis;
const unsigned int blitzZeiten2[] = {120, 1100, 120, 1100};
const byte anzahlBlitzZeiten2 = sizeof(blitzZeiten2) / sizeof(blitzZeiten2[0]);
byte blitzZeitenNr2;
unsigned long blitzMillis2;
// hier werden die Programme definiert
const byte anzahlProgramme = 9, anzahlLeds = sizeof(LED_AUSGAENGE);
const boolean programme[anzahlProgramme][anzahlLeds] = {
{0, 0, 0, 0, 0, 0, 0, 0, 0},
{1, 0, 0, 0, 0, 0, 0, 0, 0},
{1, 1, 0, 0, 0, 1, 0, 0, 0},
{1, 1, 0, 0, 0, 1, 1, 0, 0},
{1, 1, 0, 0, 0, 1, 1, 1, 1},
{1, 0, 0, 1, 1, 0, 0, 0, 0},
{1, 1, 1, 1, 1, 1, 0, 0, 0},
{1, 1, 1, 1, 1, 1, 1, 0, 0},
{1, 1, 1, 1, 1, 1, 1, 1, 1}
};
void prgwechsel() {
Serial.print("Sensorwert = " );
Serial.println(sensorWert);
Serial.print("prgNr: ");
Serial.print(prgNr);
Serial.print(" IOs:");
for (byte j = 0; j < anzahlLeds; j++) {
digitalWrite(LED_AUSGAENGE[j], programme[prgNr][j]); // LED schalten
Serial.print(" ");
Serial.print(programme[prgNr][j]);
}
Serial.println();
blitz = digitalRead(LED_AUSGAENGE[blitzLed]);
blitzZeitenNr = 0;
blitzMillis = aktMillis;
blitz2 = digitalRead(LED_AUSGAENGE[blitzLed2]);
blitzZeitenNr2 = 0;
blitzMillis2 = aktMillis;
}
void setup() {
Serial.begin(9600);
Serial.println("Anfang");
pinMode(taster, INPUT_PULLUP);
for (byte j = 0; j < anzahlLeds; j++) {
pinMode(LED_AUSGAENGE[j], OUTPUT);
}
prgwechsel(); // Anfangsstatus -> alles Aus
aktTaster = digitalRead(taster);
altTaster = aktTaster;
}
void loop() {
aktMillis = millis();
sensorWert = analogRead(eingang);
if (sensorWert > SCHWELLE + 12) // Nacht
{
if (prgNr <= TagNachtOffset && prgNr > 0)
{
prgNr += TagNachtOffset;
prgwechsel();
}
}
if (sensorWert < SCHWELLE - 12) // Tag
{
if (prgNr > TagNachtOffset && prgNr > 0)
{
prgNr -= TagNachtOffset;
prgwechsel();
}
}
altTaster = aktTaster;
aktTaster = digitalRead(taster);
if (!altTaster && aktTaster) {
delay(30);
prgNr++;
prgNr = prgNr % anzahlProgramme;
prgwechsel();
}
if (blitz && (aktMillis - blitzMillis >= blitzZeiten[blitzZeitenNr])) {
digitalWrite(LED_AUSGAENGE[blitzLed], !digitalRead(LED_AUSGAENGE[blitzLed]));
blitzMillis = aktMillis;
blitzZeitenNr++;
blitzZeitenNr = blitzZeitenNr % anzahlBlitzZeiten;
}
if (blitz2 && (aktMillis - blitzMillis2 >= blitzZeiten2[blitzZeitenNr2])) {
digitalWrite(LED_AUSGAENGE[blitzLed2], !digitalRead(LED_AUSGAENGE[blitzLed2]));
blitzMillis2 = aktMillis;
blitzZeitenNr2++;
blitzZeitenNr2 = blitzZeitenNr2 % anzahlBlitzZeiten2;
}
}