The Official Raspberry Pi Projects Book - Projects_Book_v4

(singke) #1

Tutorial STEP BY STEP


(^138) The Official Raspberry Pi Projects Book raspberrypi.org/magpi
BUILD THE
MARAUDER’S CLOCK
Know when your family get home with this beautiful Harry Potter-inspired clock
e all love the many visual elements in the Harry
Potter movies, and this project combines two
of the most iconic: the Marauder’s Map and
the Weasley ‘who is home?’ Clock. The project uses a
Raspberry Pi to detect the presence of people on the
network and an Arduino Uno to control the clock hands.



STEP-01
Preparing the setup
We start the project by setting up the Raspberry Pi and
Explorer HAT Pro. Install the libraries for the Explorer
HAT Pro using the tutorial on the Pimoroni GitHub page
here: magpi.cc/2lOfDOk. In this project we will be using
two of the 5 V DC outputs from the HAT to activate a
relay. Note: These ports don’t actually output 5 V, but
connect to ground when activated.
STEP-02
Configure the code
Clone the Python code from magpi.cc/2lOfkTJ.
\ou will need to find the MDF addresses for each
W
Servos
(continuous and
position)
Watch hands
Arduino Uno
magpi.cc/
2lO4uNA
2× Mini
breadboard
magpi.cc/
FidIZR
Transparent
medium
breadboard
magpi.cc/
wRHunb
Pimoroni
Explorer HAT Pro
magpi.cc/
2lOn5ZZ
2× 5 V mini
DC relay
magpi.cc/
2lOere6
4× LED, male-
to-male and
male-to-female
jumper cables
A box or
clock body
Background
graphics
You’ll
Need
SPENCER ORGAN
Chemistry and physics teacher,
Raspberry Pi enthusiast and Certified
RPi Educator from the West Midlands
with a passion for running workshops
and building fun, educational, and
practical things with the Pi!
themakercupboard.space
TESTING
THE CLOCK
MECHANISM
The clock
mechanism
can be tested
by connecting
digital input 1
on the Arduino
to ground.
of the devices you will be detecting on the network,
and substitute them into the code. It is important
that all the devices are on the same network as
the Pi. Rn an iRS device you can find your MDF
address under Settings > General > Wi-Fi address;
on an Android device, it’s in Settings > About phone
(or tablet) > Status.
STEP-03
Connect the servos
We then need to connect the two servos to the
Arduino. Use a breadboard to connect a common 5 V
and ground line from the Arduino. Connect the red
power cables on each of the servos to the common 5 V
line, and the brown wire to the common ground. Use
jumper cables to connect the orange signal wire of the
continuous servo to digital pin 12 on the Arduino, and
the orange signal wire of the position servo to digital
pin 11. The continuous rotation servo will become our
second hand on the clock face, and the position servo
will show whether people are home or away.
Continuous rotation servo to
give it a more clock-like feel
Positional servo used to
show who is home or away


Free download pdf