We are going to connect both sensors to the
Raspberry Pi at the same time. Neither sensor requires any extra
The PIR sensor comes with a socket and lead. Make
sure that the socket is the right way around (use the picture below)
and that the red lead goes to 5V, the black to GND and the yellow to
18 on the Cobbler.
Although the PIR sensor requires a 5V supply, its
output is a Pi-friendly 3.3V, so it can be connected directly to a
The Door Switch, uses what is called a reed
switch. These are two contacts inside a glass tube, that is then
encased in plastic. When a magnet (the other white block) is placed
near the reed switch, the contacts are drawn together and the switch
closes. Since this is just a switch, the leads can be connected
either way around.
We will use the Pi's ability to create an internal pull-up resistor on the reed-switch pin, so we don't need an external pull-up resistor.