User manual

34
17th Da
y
In the Advent calendar toda
y
•1x potentiometer
D
ispla
y
o
f
the resistor value
Today, you will measure the value o
f
a potentiometer via an
analogue input and can output the value in an App
.
C
omponents: 1x board, 1xpotentiometer 15kOhm, 4xjum
-
per (different lengths)
Th
e S
k
etc
h
The program
f
or this day is Tag17.in
o
and located in directory
T
ag1
7
. First, the two variables sensorPi
n
a
n
d
sensorVa
l
u
e
a
r
e
de
ned. The potentiometer is connected to the analogue input
5, and there
f
ore, sensorPi
n
is
set
to
A
5
:
i
nt sensorP
i
n = A5
;
i
nt sensorValue = 0;
In t
h
e met
h
o
d
l
oop, t
h
e va
l
ue is rea
d
in via
a
na
l
ogRea
d
and passed on to the wireless interface. Then the
program will wait for 2000ms before reading the value again
:
void loop()
{
sensorValue = analogRead
(
sensorPin
);
HC05.print
(
“value potentiometers = “
);
HC05.println(sensorValue)
;
delay
(
2000
);
}
T
h
e Ap
p
The texts are displa
y
ed usin
g
the App
Se
ri
a
l Bl
uetoot
h T
e
rmin
al
. First, connect to the IoT-board. You will
see t
h
e
p
otentiometer va
l
ue t
h
en
.
17. Da
y
A potentiometer is just an analogue sensor from the program’s point of view
.
15007-3 Conrad Adventskalender Internet of Things 2017_en.indd 3415007-3 Conrad Adventskalender Internet of Things 2017_en.indd 34 13.08.2017 17:03:1713.08.2017 17:03:17