I would like to thank you GoForSmoke for that example, I have actually learned quite a bit even from such a short sketch.
I am in the process of trying to start learning how to "optimize" my code. i have big projects but I feel they could be improved by things you mention in your example.
So for example to invert a led I was doing
// if the LED is off turn it on and vice-versa:
ledState = ledState ^ 1; // ^ is logical XOR, true if the values are different
// using logic operations can save a lot of tedious, pain to debug if's
I dont know the actual benefits but the second options sounds like more efficient, dont know why.
I would like to ask you the reason for this changes, the actual improvement it makes, please if you can, give me a hand understanding it.
changed time variables to be ALL unsigned longs, as they should be.
what are the benefits of defining it as "unsigned" as oppose to just long?
added UL to numbers being assigned to unsigned longs as should be.
I have never added the "UL", where should it be added? why?
I have used google but im not hitting the right buttons I guess.
Thanks for your help, hope more examples are "optimised" as you just did with this one.