Just wondering how are you with browser bookmarks?
Reason is that my Arduino references are all folder-organized bookmarks to mostly Arduino site pages.
When I code, I have a browser up with tabs to all the references I need to be sure of what I read and write.
Some basic basics.
Ideas and goals.
Arduino Libraries reference.
Details on the boards including pin maps, enough for intermediate level projects.
Beginner-Intermediate level Arduino C language reference. Maybe the page you need most now.
Assigning powers of 2 to A,B,C,D actually obfuscates the code. It reads much more clearly with numerical constants, and the variables have no use other than to replace them. A step in the wrong direction.
Santapost
I used timercopy to check if the code worked. You can delete as not required.
GoForSmoke
You are right, I meant to subtract the value. The code raises the output pin high after a maximum of 15 seconds and does no more, so 50 days will not be a problem.
Aarg
Agree with you entirely. I was just working with Santapost code, although I did take the delay out. My intention was to get Santapost over a hurdle, not to redesign the code.
Zardof:
I was just working with Santapost code, although I did take the delay out. My intention was to get Santapost over a hurdle, not to redesign the code.
G
You're alright, at least you gave the OP some code help.
Those unsigned longs for time are what's taught but really any unsigned integer variable can be used for timing because of rollover (that always works). The smaller the unsigned variable used, the shorter maximum it can time to is all.
With byte (8 bit unsigned) you can time up to 255 millis (or micros). I used them for debouncing where I only have to count to 2 (or a few depending on how dirty the contact switch is). If you want 1/4 second or less timers, byte is right.
With word (16 bit unsigned) you can time up to 65.535 seconds in millis. If it takes a minute or less, 16-bit time variables will do.
With unsigned lon long (64 bit unsigned) you can milli time to billions of years.
The shorter the variable, the less RAM it uses and the faster it runs.
byte myTime;
myTime = ( millis() & 255 ); // 8 bit time, for 16 bit use & 65535
@GoforSmoke, if you're really going for efficiency, you could make an "altMillis()" that only produces 8 or 16 bit values. You know it would be faster.