The Official Raspberry Pi Projects Book - Projects_Book_v4

(singke) #1

Tutorial STEP BY STEP


(^108) The Official Raspberry Pi Projects Book raspberrypi.org/magpi
SUNRISE
ALARM
Use a breadboard and simple components to sense light levels and
activate a loud (and blinky) alarm to wake you up each morning!
ith the help of some exciting code and
some clever electronics, you can use your
Raspberry Pi to read an analogue signal from a
photoresistor without the need for a conversion chip!
Armed with this power, you can measure the ambient
light level and trigger an effective alarm. The project is
designed as an extension to the projects found in the
Monk Makes Raspberry Pi Electronics Starter Kit.
W
Dual LEDs flash to stir
you from your slumber



2× LEDs
Light-dependant
resistor (LDR)
330 nF ceramic
capacitor
Buzzer
2× 1 kΩ
resistors
2× 4 70 Ω
resistors
6× Male-to-
female jumper
wires
3× Male-to-male
jumper wires
Or Monk Makes
Raspberry Pi
Electronics
Starter Kit
magpi.cc/
2eC95jz
You’ll
Need
HENRY BUDDEN
Following the release of the
Raspberry Pi when he was twelve,
Henry has taught himself to code
and use/break electronics.
magpi.cc/2eCbaMf



DIY


>STEP-01
Connect the resistors
Once you have the components, begin to make the
circuit by connecting up the resistors. Do this as shown
in the circuit diagram, pushing each component’s legs
into the holes in the breadboard. Ensure that the bottom
two resistors are 470 Ω (yellow, purple, and brown), and
the top two are 1 kΩ (brown, black, and red).

>STEP-02
Add the rest of the components
Next, add the LEDs, making sure that the long legs
are connected towards the bottom of the diagram,
as shown. The flat side of the LEDs should be facing
towards the 1 kΩ resistors. When connecting the
buzzer, the longest leg should be facing the bottom
of the breadboard. Finally, connect the LDR and
capacitor. These can be connected in any orientation.

>STEP-03
Connect to the Pi
Make sure your Raspberry Pi is turned off and unplugged
before you do this. Using the three male-to-male
jumper wires, connect the ground to the two LEDs, the
buzzer, and the LDR as shown in the diagram. Next, use
the remaining male-to-female jumper wires to connect
the breadboard to the Raspberry Pi’s GPIO pins.

>STEP-04
Install the software
Turn on your Raspberry Pi, and ensure it is connected
to the internet. Using the Terminal, clone the GitHub
repository containing the code to your Pi’s SD card
using the command:

git clone https://github.com/henrybudden/
rpesk-advanced/

Once the files have downloaded and you have
returned to the command prompt, change into the

Even the deepest sleeper couldn’t
sleep through the (annoying) noise
made by the buzzer!
Free download pdf