analogreadresolution

Status
Not open for further replies.

Wayne

Well-known member
What are the settings and does it change the read data.
I see 1023, but if I set to 6, 7, 8, 9, 10 etc., should that go up beyond 1023?
or lower if below a certain setting
 
analogReadResolution(bits) sets the bit width of the values which you get with analogRead(pin).

Thus, if bits = 10 (default), the values you can obtain with analogRead() will go from 0 to 1023.
If you change the resolution to 12, you will obtain 0 - 4095, with 6 you will obtain 0 - 63 and so on.

I general, setting the resolution to n bits, n in [1..16], you will read values from 0 to (2^n) - 1.
 
analogReadResolution(bits) sets the bit width of the values which you get with analogRead(pin).

Thus, if bits = 10 (default), the values you can obtain with analogRead() will go from 0 to 1023.
If you change the resolution to 12, you will obtain 0 - 4095, with 6 you will obtain 0 - 63 and so on.

I general, setting the resolution to n bits, n in [1..16], you will read values from 0 to (2^n) - 1.

Thanks, That is what I thought, Guess the Arduino Duo does not do this, that is why I use the Teensy 3.1 in our projects
 
The Arduino Due should theoretically do that the same way, but I never tried it out. There is one important thing: analogReadResolution() triggers a ADC initialization and self-calibration routine every time when the resolution is modified. Be sure to let some time go before you do the first analogRead() after that, so that the initialization and calibration cycle can accomplish.
 
It is done at the beginning of my setup, and right after is the tft display and I do a 1.5 sec delay. I'm thinking of making it 2 or 3 secs.
 
Status
Not open for further replies.
Back
Top