User manual
40
23rd Day
In the Advent calendar toda
y
•1x jumper cabl
e
Code breaker
T
oday’s project is a little game: You will set a code in an App.
T
hen you will submit this code to the IoT-board. Now the code
must
be
e
n
te
r
ed
wi
t
h
t
h
e
butto
n. If
t
h
e
code
h
as
bee
n
e
n
te
r
ed
correctl
y
, the red LED will li
g
ht up and the App will displa
y
t
hat the code has been entered correctl
y
. Otherwise, the red
L
ED will not li
g
ht up and the App will displa
y
that the code has
n
ot
b
een entere
d
correct
l
y
.
C
om
p
onents
:
1x board, 1xbutton, 1xLED red with dro
p
-
p
ing resistor, 1xpotentiometer 15 kOhm, 5x jumper (diffe-
r
ent lengths
)
Th
e S
k
etc
h
T
he program
f
or this day is Tag23.in
o
and located in directory
T
ag2
3
. Th
e
code
i
s
sub
mi
tted
in
t
h
e
fo
rm
of
C
NNN
:
if
(
Text.startsWith
(
“C”
)){
anzahlTasten = Text.substring
(
Text
.
indexOf(“C”)+1).toInt()
;
All in all, the player has fi ve seconds time to enter the code:
interval = millis
()
– start
;
Serial.println
(
interval
)
;
while (interval < 5000) {
pressed += tasterAuslesen
();
delay
(
100
)
;
interval = millis
()
– start;
}
T
he
m
ethod
taste
rA
uslesen
wi
ll
c
h
ec
k
w
h
et
h
er a
b
utton
h
as
b
een pus
h
e
d
. T
h
e program
will wait
f
or 100ms between checks. The result is returned to the App:
if (
p
ressed == anzahlTasten) {
HC05.print
(
“JA”
);
di
g
italWrite(redPin, HIGH);
delay(5000)
;
digitalWrite
(
redPin, LOW
)
;
} e
l
se
{
HC05.print(“NEIN”)
;
}
T
h
e Ap
p
T
h
e A
pp
F
a
r
bcode.a
i
a
h
as t
h
ree
b
uttons an
d
two
l
a
b
e
l
s. One
l
a
b
e
l
wi
ll
d
isp
l
ay t
h
e co
d
e
that has been entered and the second one the game status. I
f
the code has been entered
correctly via the hardware button, the background colour o
f
the game status label is set to
g
reen; ot
h
erwise, it wi
ll
b
e re
d
.
T
h
e co
d
e is put in interim storage in a g
l
o
b
a
l
varia
bl
e an
d
t
h
en su
b
mitte
d
b
y B
l
uetoot
h.
Sen
d
Tex
t
.
For the button to work well, a voltage divider is set up via the potentiometer. You can also
replace the jumpers with the jumper cables.
A coloured label shows whether the code has been
e
ntered correctly via the hardware button or not.
2
3. Da
y
15007-3 Conrad Adventskalender Internet of Things 2017_en.indd 4015007-3 Conrad Adventskalender Internet of Things 2017_en.indd 40 13.08.2017 17:03:2113.08.2017 17:03:21










