Timeline for Managing timer intervals using millis at random intervals
Current License: CC BY-SA 3.0
5 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jan 19, 2016 at 8:51 | comment | added | frarugi87 |
@jwpat7 I agree that if the code is nearly identical the switch/case can be rewritten in a more concise form, but often (almost always) you have to do something else in the cases (and that's why when dealing with simple - and complex - state machines my mind always implements it as switch/case ). In this case, however, this could be simplified. The while, however, is much more secure than the if. Since previousMillis is not reset to millis() but just incremented (more precise), if some function blocks the thread for too much time you can lose one step; with the while you can recover it
|
|
Jan 19, 2016 at 6:37 | comment | added | Lokanath | if(received_sms){} block made my day " previousMillis=millis()" inside that will now allow me to get the offset from the point i recieved the SMS ,,Thanks You | |
Jan 19, 2016 at 6:32 | vote | accept | Lokanath | ||
Jan 18, 2016 at 18:12 | comment | added | James Waldby - jwpat7 |
(a) Using a switch /case statement to select which relay to work on, with four blocks of nearly identical code (instead of using an array with pin numbers, and a single block of code) is odious. (b) Although the while (in the if (currentState < 4) block) works ok, it functions as an if statement and IMO should be written as such.
|
|
Jan 18, 2016 at 16:54 | history | answered | frarugi87 | CC BY-SA 3.0 |