Timeline for Sketch does not work without delay() or other complex functions like digitalWrite()
Current License: CC BY-SA 3.0
13 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Aug 21, 2016 at 7:47 | comment | added | Edgar Bonet | With unsigned ints, 3000 − 60000 = 8536. Unsigned numbers follow the rules of modular arithmetic, which make the overflow irrelevant as long as you compare durations instead of timestamps. | |
Aug 21, 2016 at 0:19 | answer | added | Nick Gammon♦ | timeline score: 0 | |
Aug 20, 2016 at 21:25 | vote | accept | user2882440 | ||
Aug 20, 2016 at 20:46 | comment | added | user2882440 | @Majenko , indeed it is!) Thank you! | |
Aug 20, 2016 at 20:45 | comment | added | user2882440 | @ Dirk Grappendorf , thank you for that, but it also uses millis(), and it is too costly in my current project. | |
Aug 20, 2016 at 20:41 | comment | added | user2882440 | @Edgar Bonet , i was thinking about it, but what happens, when previous millis() value is 60000, and than it overflowed and current millis() is 3000? 3000-60000=-57000, and who knows what will arduino do next... Or did i miss smth? Tell me please if so, that would a nice solution. | |
Aug 20, 2016 at 20:38 | history | edited | user2882440 | CC BY-SA 3.0 |
added reworked and benchmarked sketch to the end
|
Aug 20, 2016 at 14:33 | history | edited | user2882440 | CC BY-SA 3.0 |
edited title
|
Aug 20, 2016 at 13:16 | comment | added | Edgar Bonet | “millis() uses long variable (which is bad for cpu time and ram)” If you never need to compare timestamps more than 65 seconds apart, then you can do the timekeeping with 16-bit unsigned integers. | |
Aug 20, 2016 at 12:19 | answer | added | jantje | timeline score: 1 | |
Aug 20, 2016 at 12:02 | comment | added | Dirk Grappendorf | The typical design pattern used to perform a delay without delay() is described here: arduino.cc/en/Tutorial/BlinkWithoutDelay | |
Aug 20, 2016 at 11:58 | comment | added | Majenko |
Without delay() it is doing exactly what you tell it. It is blinking the LED - just far too fast for you to see. Try using values in the hundreds of millions instead of just a few hundred for your counter.
|
|
Aug 20, 2016 at 11:35 | history | asked | user2882440 | CC BY-SA 3.0 |