Cool Mel! Only you could come up with this. I watch the short video of the flashers, and seen the picture, but everything beyond that, which must be your "sketch", was so far over my head, it got lost in the stars!
I can't wait until I see your emergency vehicles flashing.
Mike.
My You Tube
I'm lost too and think you are a wizard, but it looks like it starts off with a repetitive pattern. By the end of the video it changes
Henry
COB Potomac & Northern
Shenandoah Valley
looks pretty good ..
will come in handy for some people
It certainly has come in handy for me, Mel. I am looking for a way to dump serial data from an Arduino to a Visual Basic serial input so I can graphically display block status, etc. I was afraid that using Serial.println at the end of each loop would overload the VB serial buffer. However, using a delay statement to prevent this would stop the program execution. Your millis() based approach should take care of that.
This is sort of what I do for my servo controller, so it can be pollign the buttons for one servo while it is noving the other. Primitive multitaskign but it works.
The code I based mine one comes from searching for something like "arduino more than one thing at a time". There's a library someone wrote that wraps up the whole method of using millis. There's also a newer version than the one I used but when I checked it out there was some reason I didn;t use it - it did more than the one I used, but I didn;t need those added features, but it also did something differently that needed more function calls or something to work. I'd post a link to where I first found it, it started out as a discussion on using millis() and had an example that moved a servo and had a button toggle an LED and it all ran at the same time, but it's a 7 page thread that for a while degenerated into a bunch of so-called programming experts callign each other names over the used of break() in a case statement - to listen to some of them you'd think someone suggested using a goto! Anyway, a while back I did post my code for the servo controller, and you can see the library and the calls to it in there. In the background it is effectively doing the millis() calculations, but you don't really have to know that. It's the Metro library (I guess from Metronome, since Arduinos were targeted at artists). You declare a Metro object for each task, with a parameter of how many milliseconds you want:
Metro hbMetro = Metro(750);
and then within the loop() function you just test it
if (hbMetro.check() == 1) {
hbstate = ! hbstate;
digitalWrite(HBLED, hbstate);
}
and you have an LED that blicks on and off a 750ms intervals. If 750ms has not yet elapeds, the if test simple falls through and you cna have a test of another Metro object, or do something else.
It's primitive multitasking - because if you do somethign that takes longer than the interval you are testing for, it will miss - it's cooperative multitasking, like Windows prior to Windows 2000. If, for example my next line after the if block in that example was delay(1000) the LED would flash very irregularly.
--Randy
Modeling the Reading Railroad in the 1950's
Visit my web site at www.readingeastpenn.com for construction updates, DCC Info, and more.