int FLR1_State=1;long previousMillis_FLR1 = 0; // will store last time LED was updated// the follow variables is a long because the time, measured in miliseconds,// will quickly become a bigger number than can be stored in an int.long Interval_FLR1= 70; // interval at which to blink (milliseconds)int FLR1 = 10; // Flitser 1void setup() { Serial.begin(9600); pinMode(FLR1, OUTPUT); }void loop() { unsigned long currentMillis = millis(); // FLITSER 1 if(currentMillis - previousMillis_FLR1 > Interval_FLR1) { // save the last time you blinked the LED previousMillis_FLR1 = currentMillis; switch (FLR1_State) { case 1: digitalWrite(FLR1, HIGH); // set the LED on break; case 2: digitalWrite(FLR1, LOW); // set the LED on break; case 3: digitalWrite(FLR1, HIGH); // set the LED on break; case 4: digitalWrite(FLR1, LOW); // set the LED on break; case 5: digitalWrite(FLR1, LOW); // set the LED on break; case 6: digitalWrite(FLR1, LOW); // set the LED on break; case 7: digitalWrite(FLR1, LOW); // set the LED on break; case 8: digitalWrite(FLR1, LOW); // set the LED on break; } FLR1_State=FLR1_State+1; if (FLR1_State > 8) { FLR1_State=1; } } }
int delaytime;int FLR1_State=1;long previousMillis_FLR1 = 0; // will store last time LED was updated// the follow variables is a long because the time, measured in miliseconds,// will quickly become a bigger number than can be stored in an int.long Interval_FLR1= 70; // interval at which to blink (milliseconds)int FLR1 = 10; // Flitser 1void setup() { Serial.begin(9600); pinMode(FLR1, OUTPUT); delaytime = 100;}void loop() { unsigned long currentMillis = millis(); // FLITSER 1 if(currentMillis - previousMillis_FLR1 > Interval_FLR1) { // save the last time you blinked the LED previousMillis_FLR1 = currentMillis; switch (FLR1_State) { case 1: digitalWrite(FLR1, HIGH); // set the LED on break; case 2: digitalWrite(FLR1, LOW); // set the LED on break; case 3: digitalWrite(FLR1, HIGH); // set the LED on break; case 4: digitalWrite(FLR1, LOW); // set the LED on break; case 5: digitalWrite(FLR1, LOW); // set the LED on break; case 6: digitalWrite(FLR1, LOW); // set the LED on break; case 7: digitalWrite(FLR1, LOW); // set the LED on break; case 8: digitalWrite(FLR1, LOW); // set the LED on break; } FLR1_State=FLR1_State+1; if (FLR1_State > 8) FLR1_State=1; } }
int FLR1_State;unsigned long previousMillis_FLR1; // will store last time LED was updatedunsigned long currentMillis;int Interval_FLR1= 70; // interval at which to blink (milliseconds)int FLR1 = 10; // pinnummer Flitser 1void setup() { Serial.begin(9600); pinMode(FLR1, OUTPUT); }void loop() { // FLITSER 1 for (FLR1_State=1; FLR1_State<9 ;FLR1_State++) { currentMillis = millis(); if(currentMillis > previousMillis_FLR1 + Interval_FLR1) { // save the last time you blinked the LED previousMillis_FLR1 = currentMillis; switch (FLR1_State) { case 1: digitalWrite(FLR1, HIGH); // set the LED on break; case 2: digitalWrite(FLR1, LOW); // set the LED off break; case 3: digitalWrite(FLR1, HIGH); // set the LED on break; case 4: digitalWrite(FLR1, LOW); // set the LED off break; // In states 5-8 FLR1 will remain LOW } } }}
switch (FLR1_State) { case 1: digitalWrite(FLR1, HIGH); // set the LED on break; case 2: digitalWrite(FLR1, LOW); // set the LED off break; case 3: digitalWrite(FLR1, HIGH); // set the LED on break; case 4: digitalWrite(FLR1, LOW); // set the LED off break; // In states 5-8 FLR1 will remain LOW }
switch (FLR1_State) { case 1: case 3: digitalWrite(FLR1, HIGH); // set the LED on break; default: digitalWrite(FLR1, LOW); // set the LED off break; }
if ((FLR1_State == 1) || (FLR1_State == 3)) digitalWrite(FLR1, HIGH); // set the LED on else digitalWrite(FLR1, LOW); // set the LED off
... Ik ben er nu even mee gestopt, maar zal morgen nog eens denken of het ook met minder pinnen kan.
Klopt het dat wanneer het sein ook nog is voorzien van een cijferbak (uit, aan, knipperend) je bij jouw methode dan in totaal zeven pinnen en ook zeven DCC adressen nodig hebt?