User manual
1
0
3rd Day
In the Advent calendar toda
y
•1x LED red with dropping resisto
r
•1x switching wir
e
F
lashing light
Today, you will make an LED
fl
ash at a
f
requency o
f
2Hz.
C
omponents: 1x board, 1xLED red with dropping resisto
r
Th
e progra
m
The program
f
or this day is called Tag03.
i
n
o
an
d
l
ocate
d
in
d
irectory
T
ag03
.
const
i
nt ledP
i
n = 2
;
i
nt ledState = LOW
;
void setup()
{
pinMode
(
ledPin, OUTPUT
);
}
void loop
()
{
if (ledState == LOW) ledState = HIGH
;
e
l
se
l
e
d
State = LOW
;
digitalWrite
(
ledPin, ledState
);
delay(500)
;
}
How t
h
e pro
g
ram wor
k
s
if
(
ledState == LOW
)
ledState = HIGH
;
e
l
se
l
e
d
State = LOW;
T
he
v
a
ri
able
ledState
recor
d
s w
h
et
h
er t
h
e LED is
l
it or not. Initia
lly
, t
h
e varia
bl
e
h
as t
h
e va
l
ue L
O
W
.
T
h
i
s
va
l
ue is switc
h
e
d
ever
y
500ms via delay
(
500
)
. This makes the LED
fl
ash.
You do not need any separate resistor, since the LED already has an integrated one
.
3. Da
y
15007-3 Conrad Adventskalender Internet of Things 2017_en.indd 1015007-3 Conrad Adventskalender Internet of Things 2017_en.indd 10 13.08.2017 17:03:0113.08.2017 17:03:01










