Reference.AnalogReadResolution History

Show minor edits - Show changes to markup

September 16, 2012, at 11:49 PM by Tom Igoe -
Changed lines 16-17 from:

bits: determines the resolution (in bits) of the value returned by analogRead() function. Valid arguments are between 1 and 32. You can set resolutions higher than 12 but values returned by analogRead() will suffer approximation. See the note below for details.

to:

bits: determines the resolution (in bits) of the value returned by analogRead() function. You can set this 1 and 32. You can set resolutions higher than 12 but values returned by analogRead() will suffer approximation. See the note below for details.

Changed lines 24-25 from:

If a resolution higher than the hardware capabilities is set, the Arduino will only report back at its highest resolution padding the extra bits with zeros.

to:

If you set the analogReadResolution() value to a value higher than your board's capabilities, the Arduino will only report back at its highest resolution padding the extra bits with zeros.

Changed lines 28-31 from:

If a resolution lower than the hardware capabilities is set, the extra least significant bits read from the ADC will be discarded.

Note that using a 16 bit resolution (or any resolution higher than actual hardware capabilities) allows to write sketches that automatically handles superior ADC devices when these become available on future boards without changing a line of code.

to:

If you set the analogReadResolution() value to a value lower than your board's capabilities, the extra least significant bits read from the ADC will be discarded.

Using a 16 bit resolution (or any resolution higher than actual hardware capabilities) allows you to write sketches that automatically handle devices with a higher resolution ADC when these become available on future boards without changing a line of code.

September 16, 2012, at 07:19 PM by Cristian -Vacuum- Maglie -
Changed lines 9-10 from:

The Due has 12-bit ADC capabilities that can be accessed by changing the resolution. This will return values from analogRead() between 0 and 4095.

to:

The Due has 12-bit ADC capabilities that can be accessed by changing the resolution to 12. This will return values from analogRead() between 0 and 4095.

Changed lines 16-17 from:

bits: determines the resolution (in bits) of the ADC. Valid arguments are between 0 and 12. You can set the resolution larger than 12, but higher values are ignored. See the note below for details.

to:

bits: determines the resolution (in bits) of the value returned by analogRead() function. Valid arguments are between 1 and 32. You can set resolutions higher than 12 but values returned by analogRead() will suffer approximation. See the note below for details.

Changed lines 24-27 from:

If a resolution larger than the hardware capabilities is set, the Arduino will only report back at its highest resolution. For example, using the Due with analogReadResolution(16) will only give you a 12-bit number.

If a resolution lower than the hardware capabilities is set, the least significant bits will be ignored.

to:

If a resolution higher than the hardware capabilities is set, the Arduino will only report back at its highest resolution padding the extra bits with zeros.

For example: using the Due with analogReadResolution(16) will give you an approximated 16-bit number with the first 12 bits containing the real ADC reading and the last 4 bits padded with zeros.

If a resolution lower than the hardware capabilities is set, the extra least significant bits read from the ADC will be discarded.

Note that using a 16 bit resolution (or any resolution higher than actual hardware capabilities) allows to write sketches that automatically handles superior ADC devices when these become available on future boards without changing a line of code.

Changed lines 35-37 from:

void setup(){

 // open a serial connection
 Serial.begin(9600); 
to:

void setup() {

  // open a serial connection
  Serial.begin(9600); 
Changed lines 40-51 from:

void loop(){

 // read the input on A0 at default resolution (10 bits)
 // and send it out the serial connection 
 analogReadResolution(10);
 Serial.print("ADC 10-bit (default) : ");
 Serial.print(analogRead(A0));
 delay(5);
 // change the resolution to 12 bits and read A0
 analogReadResolution(12);
 Serial.print(", 12-bit : ");
 Serial.print(analogRead(A0));
 delay(5);
to:

void loop() {

  // read the input on A0 at default resolution (10 bits)
  // and send it out the serial connection 
  analogReadResolution(10);
  Serial.print("ADC 10-bit (default) : ");
  Serial.print(analogRead(A0));

  // change the resolution to 12 bits and read A0
  analogReadResolution(12);
  Serial.print(", 12-bit : ");
  Serial.print(analogRead(A0));
Changed lines 53-61 from:
 analogReadResolution(12);
 Serial.print(", 16-bit : ");
 Serial.print(analogRead(A0));
 delay(5);
 // change the resolution to 8 bits and read A0
 analogReadResolution(8);
 Serial.print(", 8-bit : ");
 Serial.println(analogRead(A0));
 delay(5);
to:
  analogReadResolution(16);
  Serial.print(", 16-bit : ");
  Serial.print(analogRead(A0));

  // change the resolution to 8 bits and read A0
  analogReadResolution(8);
  Serial.print(", 8-bit : ");
  Serial.println(analogRead(A0));

  // a little delay to not hog serial monitor
  delay(100);
September 12, 2012, at 01:08 AM by Scott Fitzgerald -
Changed lines 7-8 from:

Sets the size (in bits) of the value returned by analogRead(). It defaults to 10 bits (returns values between 0-1023) for backward compatibility.

to:

Sets the size (in bits) of the value returned by analogRead(). It defaults to 10 bits (returns values between 0-1023) for backward compatibility with AVR based boards.

Changed lines 16-17 from:

bits: determines the resolution (in bits) of the ADC. You can set the reolution larger than 12, and less than 10, see the note below for how this is dealt with.

to:

bits: determines the resolution (in bits) of the ADC. Valid arguments are between 0 and 12. You can set the resolution larger than 12, but higher values are ignored. See the note below for details.

August 26, 2012, at 02:03 AM by Scott Fitzgerald -
Added lines 5-6:

analogReadResolution() is an extension of the Analog API for the Arduino Due.

August 24, 2012, at 11:53 PM by Scott Fitzgerald -
Changed lines 1-2 from:

analogReadResolution(bits)

to:

analogReadResolution()

August 24, 2012, at 11:53 PM by Scott Fitzgerald -
Added lines 9-11:

Syntax

analogReadResolution(bits)

Changed line 62 from:
to:
August 24, 2012, at 07:06 PM by Scott Fitzgerald -
Changed lines 5-6 from:

Sets the size (in bits) of the value returned by analogRead(). It defaults to 10 bits (returns values between 0-1023) for backward compatibility. This has no effect on Arduino Uno or other ATmega based boards.

to:

Sets the size (in bits) of the value returned by analogRead(). It defaults to 10 bits (returns values between 0-1023) for backward compatibility.

August 24, 2012, at 06:43 PM by Scott Fitzgerald -
Added lines 1-59:

Share