Hi Guys.
I am trying to animate the lights indicated on an admiralty chart. This means flashing 20+ LEDs at different rates I.e. one light will flash 4 times then be of for 10 secs. Another light will be 6 quick flashes and one slow another light will be 2 long flashes etc. Any ideas? I am using a mega 2560
maybe this topic will help you.
I think this would be more helpful, see reply #4.
http://forum.arduino.cc/index.php?topic=179761.0
You don't need to read all the buttons as it will be running continuously.
Change the times from the microseconds I used to the rates you want, and add more states for the cases where it flashes, has a pause, flashes, has a pause.
On a lighter note, one of my favourite scenes from The IT Crowd
This is some code I wrote for a Christmas tree heat sink:-
/* Random blinking lights
for use on a christmas tree
By Mike Cook
*/
#define numberOfLights 16
byte pins[] = {2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18};
byte pinState[numberOfLights];
long int changeTime[numberOfLights];
int flashRate[numberOfLights];
long flashChange; // how often to change the flashing patterns
void setup() {
for(int i = 0; i< numberOfLights; i++) {
pinMode(pins[i], OUTPUT);
changeTime[i] = millis() + random(1000, 200);
pinState[i] = LOW;
}
setFlashTime();
}
void loop() {
for(int i = 0; i < numberOfLights; i++) {
if(changeTime[i] <= millis()) {
pinState[i] = ~pinState[i];
digitalWrite(pins[i], pinState[i]);
changeTime[i] = millis() + flashRate[i];
}
}
if(flashChange <= millis()) setFlashTime();
}
void setFlashTime(){
for(int i=0; i<numberOfLights; i++){
flashRate[i] = random(200, 1500);
}
flashChange = millis() + 100000; // next time to change pattern
}
In my code repository (see link below) there is a sketch called multiblink that does what you seem to need.
Thanks Guys.
I'll try some of your ideas.
Hi,
A friend of mine just asked about doing exactly the same thing!
Below is my code. It works simply on a large array of on/off switches. It steps in half seconds and loops every 120 steps which seems to be enough to fit all the light sequences in where we are (Belfast Lough). It fits Q.G/R, 3s, 5s, 6s, 7.5s.
There is a python script to generate the sequence. It should be relatively easy to understand.
Note, the individual bytes are read right to left but the array of bytes for a given step are read right to left...just to be confusing!
Any questions, let me know.
BLlights.ino (5.59 KB)
generate_sequence.py (2.16 KB)
marco_c:
In my code repository (see link below) there is a sketch called multiblink that does what you seem to need.
HuwG:
Hi Guys.
I am trying to animate the lights indicated on an admiralty chart. This means flashing 20+ LEDs at different rates I.e. one light will flash 4 times then be of for 10 secs. Another light will be 6 quick flashes and one slow another light will be 2 long flashes etc. Any ideas? I am using a mega 2560
Hi I'm new to Arduino and just joined this forum as I am also trying to do this with an admiralty chart. I have tried to look at some of the examles quoted in some of the posts here but cannot open the .ino files and the .py files.
Any help appreciated as I'm a total newbie to coding etc.
Do you have the IDE installed? That will open the .ino files; copy & paste the sketch above, use Save As when done to put it into new folder. Notepad++ is a good editor for programs as well.