6-1 - Potentiometer and Analog Input
6-1 - Potentiometer and Analog Input
Input +5V
potentiometer
To GND
Arduinos and “Analog Sensors”
Arduino
variable=analogRead(pin);
example:
sensorValue=analogRead(A0);
After this line, the variable sensorValue contains the value that was read at that moment.
Input Voltage and Input Voltage comes in the range of
Sensor Values 0.00V to 5.00V
int inputLevel=analogRead(inputPin);
614 716 798 491 225 102 307 512 818 1003
3.0V 3.5V 3.9V 2.4V 1.1V .5V 1.5V 2.5V 4.0V 4.9V
5.0--- x
Input Voltage (V)
4.0--- x x
x
3.0--- x
x x
2.0---
x
1.0--- x
x
| | | | | | | | | |
1 2 3 4 5 6 7 8 9 10
Time (s)
Sampling Rate
In this example, the sampling rate changes as the delay() value changes. When the input
value is greater, the delay is longer, and the sampling rate is slower.
Schematic and Wiring
a Potentiometer
Schematic Symbol
for Potentiometer
Since it is a variable resistor with two
outputs, the symbol looks like a resistor
with an extra output.
Notice:
Voltage In
Voltage Out (to Analog In)
Ground
Wiring a POT with a breadboard
.. .. .. .. .. .. .. .. .. .. .. .. .
.+-. ..... ..... .
GND ..
13
12 .. .. .. .. .. .. .. .. .. .. .. .. ..
~11 .. . ..... ..... .
~10
~9 ..
5V
8 .. .. .. .. .. .. .. .. .. .. .. .. ..
GND
7
~6 .. . ..... ..... .
..
A0
~5
4 .. .. .. .. .. .. .. .. .. .. .. .. ..
A1
A2
~3
2 .. . ..... ..... .
A3 1 ..
A5 0
.. .. .. .. .. .. .. .. .. .. .. .. ..
.. . ..... ..... .
..
.. .. .. .. .. .. .. .. .. .. .. .. ..
.. . ..... ..... .
..
.. .. .. .. .. .. .. .. .. .. .. .. ..
.. . ..... ..... .
..
.. .. .. .. .. .. .. .. .. .. .. .. ..
.. . ..... ..... .
..