Problem about mysterious output

Hi, I am new in Arduino uno. I am trying to use five thermistors to collect 100 data and transfer them into temperature each measurement period. My code runs quite well when I set the measurement_interval small(like 10 second, 20second). But as long as I set it to 60 second(which is 60000 ms), the measurement_interval automatically jump to another value I don't know where it comes from.

for example as I set the measurement_interval = 60000,
and Serial.println(measurement_interval), it gives me "14464." I don't know how can it be that.

Really need help! Thanks so much!

without posting your code only guessings can be made.

It is very likely that you use an integer-variable that can only hold values from -32767 to +37767

or instead of a comparison using "==" you might have coded a assigment "="

You should post code by using code-tags
There is an automatic function for doing this in the Arduino-IDE
just three steps

  1. press Ctrl-T for autoformatting your code
  2. do a rightclick with the mouse and choose "copy for forum"
  3. paste clipboard into write-window of a posting

best regards Stefan

Well I'd say the line of code right there is incorrect. If you changed that line to another line you'd get proper operations. Yes, that line right there.

My guess you are using an int to declare the 60000. An int on a 16 bit MCU, what's the highest number a 16 bit signed int can hold? If you'd use a UL instead you might get better luck.

Note: A 16-bit integer can store 2 16 (or 65,536) distinct values. In an unsigned representation, these values are the integers between 0 and 65,535; using two's complement, possible values range from −32,768 to 32,767. Hence, a processor with 16-bit memory addresses can directly access 64 KB of byte-addressable memory.

unsigned long sxldjngslodjhgosdjnvlxdjktyhpoeif=60000UL;

Hi, @yhe224
Welcome to the forum.

Please read the post at the start of any forum , entitled "How to use this Forum".

Can you please post your code?

Thanks.. Tom... :grinning: :+1: :coffee: :australia:

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.