Project 17: Drawer Monitor - Thames & Kosmos Code Gamer Experiment Manual

Coding workshop ? game with kosmobits
Table of Contents

Advertisement

PROJECT 17
Drawer monitor
Have you ever had the suspicion that your brother or sister
might be secretly looking through your things when you're
not home? With this drawer monitor, you will be able to
catch them! And the best thing about it is that the
perpetrator won't even know that the drawer is under
surveillance. There is no alarm, and nothing to indicate to
the culprit that his deed has been noticed. It is only when
you ask the KosmoDuino that you will know whether
someone has been peeking around!
YOU WILL NEED
› KosmoDuino in the interaction board
› Light sensor
THE PLAN
It's dark inside a closed drawer, and bright in an open one.
So you can use a light sensor to tell whether your drawer
has been opened or not.
You will be programming your KosmoDuino to do the
following:
1. After it is switched on, it will wait for a push on button 1
to be armed.
2. Once the drawer monitor is armed, it will wait for the
drawer to be closed. That's when it will start guarding
the drawer.
3. If the drawer is opened again, there are two possibilities
for what will happen then:
a) If the drawer is closed again, it will count as "drawer
was opened."
b) If you push button 2, the NeoPixel will show you how
often it was opened.
PREPARATION: MEASURING
SENSOR VALUES
To know whether the drawer has been opened or not, you
will be using the light sensor. It measures the brightness of
the light that falls on it. As long as your KosmoDuino is in
the darkness, the reading that it takes will be low. If the
drawer is opened, though, the measurement will rise.
Unfortunately, it is rarely completely dark in any closed
48
CodeGamer manual inside english.indd 48
drawer. What level of brightness signals that the drawer
has been opened? Try to find out! Start by inserting your
light sensor into the interaction board. Now you have to
find out how bright it is in daylight. Do that by reading the
sensor and outputting the reading through the serial
monitor. As usual, you will do it with the ReadSensor
sketch on page 33.
Note down the readings output by the sketch when you:
• set the light sensor out under daylight,
• set the light sensor out at dusk,
• cover the sensor completely with your hand,
• shine a flashlight on the sensor.
LIGHT
Daylight
Dusk
Shaded
Flashlight
You will need these readings later on when you think
about when the drawer should count as closed.
READING
7/19/16 12:32 PM

Advertisement

Table of Contents
loading

Table of Contents