I've been using an Arduino to monitor an experiment and using the count++ function to count the number of cycles. I noticed that when the experiment reaches around 37,000 counts it stops increasing and starts decreasing back down to zero.
I need it to keep counting up and I don't see anything in the code that could be preventing that.
Do you guys know if there is an upper limit on counts when using count++ or if there is a better counting function?
Are you sure it's 37000 not 32767? 32767 is the largest value that can be stored in an int datatype - if you increment it, it will wrap around to -32768. In this case, the solution is simple - use a larger datatype for count: A long goes up to ~2.1 billion. And if you're only ever intending to deal with positive numbers, you can declare it unsigned - unsigned int goes to 65535, unsigned long to 4.2 billion)