Good evening,
I am writing Arduino code to flash multiple LEDS at different sequences from different pins. Everything is working well, however I cant determine how to add in a Morse Code A flash sequence.
Ideally the sequence would go 1s, on 1s off, 3s on, 3s off. then repeat continuously, this would be for a MO (A) bouy
Below is the format I have used for all other lights and works well with 8 different sequences.
// A is 1s, B is 2.5s, C is 4s, D is 5s, F is 6s, G is 8s, H is 10s ,
#define aLed 2
#define bLed 3
#define cLed 4
#define dLed 5
#define fLed 6
#define gLed 7
#define hLed 8
void setup() {
pinMode(aLed, OUTPUT); //pin2 Output
pinMode(bLed, OUTPUT); //pin3 Output
pinMode(cLed, OUTPUT); //pin4 Output
pinMode(dLed, OUTPUT); //pin5 Output
pinMode(fLed, OUTPUT); //pin6 Output
pinMode(gLed, OUTPUT); //pin7 Output
pinMode(hLed, OUTPUT); //pin8 Output
}
void loop() {
BlinkA(1000);
BlinkB(2500);
BlinkC(4000);
BlinkD(5000);
BlinkF(6000);
BlinkG(8000);
BlinkH(10000);
}
void BlinkA (int interval){
static long prevMill = 0;
if ((millis() - prevMill) >= interval){
prevMill = millis();
digitalWrite(aLed, !digitalRead(aLed));
}
}
void BlinkB (int interval){
static long prevMill = 0;
if (((long)millis() - prevMill) >= interval){
prevMill = millis();
digitalWrite(bLed, !digitalRead(bLed));
}
}
void BlinkC (int interval){
static long prevMill = 0;
if ((millis() - prevMill) >= interval){
prevMill = millis();
digitalWrite(cLed, !digitalRead(cLed));
}
}
void BlinkD (int interval){
static long prevMill = 0;
if ((millis() - prevMill) >= interval){
prevMill = millis();
digitalWrite(dLed, !digitalRead(dLed));
}
}
void BlinkF (int interval){
static long prevMill = 0;
if ((millis() - prevMill) >= interval){
prevMill = millis();
digitalWrite(fLed, !digitalRead(fLed));
}
}
void BlinkG (int interval){
static long prevMill = 0;
if ((millis() - prevMill) >= interval){
prevMill = millis();
digitalWrite(gLed, !digitalRead(gLed));
}
}
void BlinkH (int interval){
static long prevMill = 0;
if ((millis() - prevMill) >= interval){
prevMill = millis();
digitalWrite(hLed, !digitalRead(hLed));
}
}
~~~
on a blank line before the code ... and same on a blank line after the code