Go Down

Topic: Mircos() returning a negative number? (Read 581 times) previous topic - next topic


I have read the reference page and believe i have understood how the micros() function works, it calculates the time since the program has been running. However it seems to be returning a negative value for me. i have a Serial.println() functions in my code that prints the word time1, time2 or time3 along with their respective values underneath the word. The serial monitor is giving me negative values however. Why might this be caused?


Why might this be caused?

You're assigning the value to a signed variable instead of an unsigned one.


And did you define time1, time2, and time3 as unsigned long variables?



Wow i am hitting myself so hard right now. That was totally it. i had them signed to integers (int) not unsinged long. Ugh that has been upsetting me for so long now. Thank you so much. That works perfect!

Go Up