Submitted by calypso_rae on Sat, 23/06/2012 - 17:27
While working on sketches, I often find it helpful to pause the code at strategic points. I can then try to work out what's going on by inspecting the Serial display window.
The attached sketch includes a simple pause() function which does this. Calls to this function can be dotted around the code as necessary. Progress is resumed when the spaceber, or any other key, is pressed followed by [CR].
By keeping pause-related calls within #ifdef DEBUG blocks, all of this functionality can be removed/re-instated at any stage by simply commenting out/in the single #ifdef DEBUG line.
In 'debug' mode, the attached sketch lumbers through the task of analysing (simulated) mains cycles. But once the relevant line is commented out, it speeds up quite a lot.
If you've ever wondered how fast an Arduino can really go, why not give this one a try ...
Debugging Arduino code
Submitted by calypso_rae on Sat, 23/06/2012 - 17:27While working on sketches, I often find it helpful to pause the code at strategic points. I can then try to work out what's going on by inspecting the Serial display window.
The attached sketch includes a simple pause() function which does this. Calls to this function can be dotted around the code as necessary. Progress is resumed when the spaceber, or any other key, is pressed followed by [CR].
By keeping pause-related calls within #ifdef DEBUG blocks, all of this functionality can be removed/re-instated at any stage by simply commenting out/in the single #ifdef DEBUG line.
In 'debug' mode, the attached sketch lumbers through the task of analysing (simulated) mains cycles. But once the relevant line is commented out, it speeds up quite a lot.
If you've ever wondered how fast an Arduino can really go, why not give this one a try ...