Hardware Reference
In-Depth Information
A/Arduino Code
Reference
analogRead
Gets the voltage value of a particular analog input pin. The values range from
0 to 1023, which represents the voltages 0 to 5. See “Analog Input” on page
75 .
If the IOREF jumper is set to 3.3V, then the maximum input
voltage for the analog input pins is 3.3 volts. However, this will
not adjust the scale of analogRead() , which will always be
based on 0 to 5 volts.
Syntax
analogRead(pin);
Parameters
pin
The pin number
Return value
integer (between 0 and 1023, representing 0 to 5 volts)
Example
int sensorReading = analogRead(0);
Gets the value from analog pin 0 and stores it in a new integer variable called
sensorReading .
analogReadResolution
Sets the resolution of the value returned by analogRead() . Galileo's analog-
to-digital converter has a resolution of up to 12 bits, but Arduino sets the
default value to 10 bits.
 
Search WWH ::




Custom Search