Timeline for Faster and lighter approximate timing code without using timer
Current License: CC BY-SA 3.0
9 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Aug 24, 2016 at 9:05 | comment | added | user2882440 | Oh, it is perfectly readable, Ijust did not know about it:) Thank you! | |
| Aug 23, 2016 at 21:17 | comment | added | Nick Gammon♦ |
I know about digitalWrite, thank you. But readability is more important - what's unreadable about: digitalWriteFast (13, onOff= !onOff);?
|
|
| Aug 23, 2016 at 9:36 | comment | added | Edgar Bonet |
millis() is one of the fastest function of the Arduino core. It just returns a copy of a global variable (timer0_millis) which is updated by a timer interrupt. The copy is performed with interrupts disabled in order to avoid a race condition. See the implementation.
|
|
| Aug 23, 2016 at 8:57 | vote | accept | user2882440 | ||
| Aug 23, 2016 at 8:32 | comment | added | user2882440 | I know about digitalWrite, thank you. But readability is more important for stackoverflow i guess) | |
| Aug 23, 2016 at 3:43 | answer | added | Nick Gammon♦ | timeline score: 3 | |
| Aug 23, 2016 at 3:33 | comment | added | Nick Gammon♦ | To put it another way, you are optimizing the wrong thing. :) | |
| Aug 23, 2016 at 3:32 | comment | added | Nick Gammon♦ |
Your use of digitalWrite will be the slow thing there, not comparing to zero, or comparing two numbers. Try looking up the digitalWriteFast library.
|
|
| Aug 23, 2016 at 3:27 | history | asked | user2882440 | CC BY-SA 3.0 |