User Tools

Site Tools


en:reference:language:analogreadresolution

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
en:reference:language:analogreadresolution [2016/01/06 07:42]
nzhu created
en:reference:language:analogreadresolution [2017/04/07 10:03] (current)
Line 1: Line 1:
-analogReadResolution()+====== ​analogReadResolution() ​====== 
 + 
 + 
 +===== Description =====
  
-Description 
  
 analogReadResolution() is an extension of the Analog API for the Arduino Due and Zero. analogReadResolution() is an extension of the Analog API for the Arduino Due and Zero.
Line 9: Line 11:
 The Due and the Zero have 12-bit ADC capabilities that can be accessed by changing the resolution to 12. This will return values from analogRead() between 0 and 4095. The Due and the Zero have 12-bit ADC capabilities that can be accessed by changing the resolution to 12. This will return values from analogRead() between 0 and 4095.
  
-Syntax+===== Syntax ​===== 
  
 analogReadResolution(bits) analogReadResolution(bits)
  
-Parameters+===== Parameters ​===== 
  
 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. 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.
  
-Returns+===== Returns ​===== 
  
 None. None.
  
-Note+===== Note ===== 
  
 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. 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.
Line 31: Line 37:
 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. 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.
  
-Example+===== Example ​=====
  
 +<code cpp>
 void setup() { void setup() {
   // open a serial connection   // open a serial connection
Line 62: Line 69:
   // a little delay to not hog serial monitor   // a little delay to not hog serial monitor
   delay(100);   delay(100);
-}+}</​code>​
en/reference/language/analogreadresolution.txt · Last modified: 2017/04/07 10:03 (external edit)