User manual

36
19th Da
y
In the Advent calendar toda
y
•1x jumper cabl
e
A
pp to select hardware Apps
Today, we will combine two
f
unctions in one circuit: Playing a
sound with the piezo and
ashing o
f
an RGB-LED. Use the App
to select the correspondin
g
function
.
C
omponents: 1x board, 1xRGB-LED with dropping resistor,
1xpiezo, 1xjumper cable
Th
e S
k
etc
h
The program
f
or this day is Tag19.in
o
and located in directory
T
ag1
9
. First, you need to de
ne the proper pins as variables:
//---- Pins of the RGB-LE
D
i
nt redP
i
n = 9;
i
nt
g
reenP
i
n = 7
;
i
nt blueP
i
n = 8
;
//
---- P
i
n P
i
ezo
i
nt p
i
ezo = 3
;
T
he
Sketch
r
eacts
to
the
co
mm
a
n
ds
p
iez
o
a
n
d
rgb
. T
he
m
eth-
ods have been taken
f
rom the
p
revious Sketches
:
if
(
Text.startsWith
(
“piezo”
))
{
aus
()
;
playMelody()
;
} else if
(
Text.startsWith
(
“rgb”
))
{
blinken
(
500
)
;
};
T
h
e Ap
p
Th
e App
A
pp_Wechsler.ai
a
h
as two
b
uttons to switc
h
b
etween t
h
e piezo an
d
RGB
.
T
he
f
unction is mapped in two when.Click blocks. Only the text to be sent is adjusted.
The blocks are very similar. In such cases, watch that you select the right
button in the when.Click block.
T
he RGB-LED doesn’t need any dropping resistors here either. Use the jumper cable to connect
t
o the ground.
T
his App uses the already-familiar elements from the other
Apps for connecting. Use Connec
t
to establish the connec-
t
ti
on.
19. Da
y
15007-3 Conrad Adventskalender Internet of Things 2017_en.indd 3615007-3 Conrad Adventskalender Internet of Things 2017_en.indd 36 13.08.2017 17:03:1813.08.2017 17:03:18