Hi everyone...
Sincere thanks for all your help... I am getting there!!!
I have juggled some code (which you have kindly brought to my attention)...
Just one further question...
As you can see, I have 3 LEDs (Pins11,12,13)
I have been able to define their blink length, and also the interval between each blink...
BUT... the last piece of my jigsaw is how to assign a PATTERN
For instance, LED 13 (below)..
In the code, it flashes for 500, and then off for 11500...
I need to get it to flash 500, off 1000, flash 500, off 10000, and then repeat all...
Any ideas how I can put this last adjustment into my code?
Again, MANY THANKS
Dara
//CONSTANTS
//ARDUINO BOARD PIN ASSIGNMENT
const int LED13Pin = 13; // the pin numbers for the LEDs
const int LED12Pin = 12;
const int LED11Pin = 11;
//INTERVALS BETWEEN BLINKS
const int LED13Interval = 11500; // number of millisecs between blinks
const int LED12Interval = 2000;
const int LED11Interval = 4750;
//BLINK DURATIONS
const int LED13blinkDuration = 500; // number of millisecs that Led's are on - all three leds use this
const int LED12blinkDuration = 150;
const int LED11blinkDuration = 250;
//VARIABLES (these will change)
//CHECKS WHETHER THE LED IS ON OR OFF
byte LED13State = LOW;
byte LED12State = LOW;
byte LED11State = LOW;
unsigned long currentMillis = 0; // stores the value of millis() in each iteration of loop()
unsigned long previousLED13Millis = 0; // will store last time the LED was updated
unsigned long previousLED12Millis = 0;
unsigned long previousLED11Millis = 0;
void setup() {
pinMode(LED13Pin, OUTPUT);
pinMode(LED12Pin, OUTPUT);
pinMode(LED11Pin, OUTPUT);
}
void loop() {
currentMillis = millis();
updateLED13State();
updateLED12State();
updateLED11State();
switchLeds();
}
void updateLED13State() {
if (LED13State == LOW) {
// if the Led is off, we must wait for the interval to expire before turning it on
if (currentMillis - previousLED13Millis >= LED13Interval) {
// time is up, so change the state to HIGH
LED13State = HIGH;
// and save the time when we made the change
previousLED13Millis += LED13Interval;
// NOTE: The previous line could alternatively be
// previousOnBoardLedMillis = currentMillis
// which is the style used in the BlinkWithoutDelay example sketch
// Adding on the interval is a better way to ensure that succesive periods are identical
}
}
else {
if (currentMillis - previousLED13Millis >= LED13blinkDuration) {
// time is up, so change the state to LOW
LED13State = LOW;
// and save the time when we made the change
previousLED13Millis += LED13blinkDuration;
}
}
}
void updateLED12State() {
if (LED12State == LOW) {
if (currentMillis - previousLED12Millis >= LED12Interval) {
LED12State = HIGH;
previousLED12Millis += LED12Interval;
}
}
else {
if (currentMillis - previousLED12Millis >= LED12blinkDuration) {
LED12State = LOW;
previousLED12Millis += LED12blinkDuration;
}
}
}
void updateLED11State() {
if (LED11State == LOW) {
if (currentMillis - previousLED11Millis >= LED11Interval) {
LED11State = HIGH;
previousLED11Millis += LED11Interval;
}
}
else {
if (currentMillis - previousLED11Millis >= LED11blinkDuration) {
LED11State = LOW;
previousLED11Millis += LED11blinkDuration;
}
}
}
void switchLeds() {
digitalWrite(LED13Pin, LED13State);
digitalWrite(LED12Pin, LED12State);
digitalWrite(LED11Pin, LED11State);
}
//=====END