Arduino Lesson 9-Analog Readings
Arduino Lesson 9-Analog Readings
Analog readings
Intro
We start to learn how to use the analog I/O interface.There
are 6 analog interface(#0-#5).These interfaces can be used
as digital interfaces(#14-#19). Potentiometer is a widely
use
analog output electronic part.So we use it to accomplish
this
experiment.
Parts required
Potentiometer x 1
Breadboard x 1
Jumper wires x 1 bundle
Connect-it-up
Here we use analog interface #0.
Experiment Intro.
We will turn the resistance of the potentiometer into
analog and read it,display on the screen at last.This
experiment contents the functions you need to use in the
future experiments.
void setup()
void loop()
delay(50);//delay 0.05 s
val=analogRead(potpin);//read value from analog interface #0
}
This program use #13(LED light) digital interface of
Arduino,the led will flash every time it got the reading.
Below is the readings.
Done! You can see the data on the screen is changing while
you twist the potentiometer.