From the course: Raspberry Pi: Home Monitoring and Control

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Explore a basic alarm system written in Python

Explore a basic alarm system written in Python - Raspberry Pi Tutorial

From the course: Raspberry Pi: Home Monitoring and Control

Start my 1-month free trial

Explore a basic alarm system written in Python

- Our alarm system program is written in a scripting language called Python, so let's take a look through the code. As before, the top line is called the shebang and you should never change that. There's a couple of import statements and GPIO.setmode is important because it's saying we're going to be using the Broadcom pin numbering system in our code. And we're going to shut off our warning messages. But here's where the interesting part comes. We're going to set pin 27 to be Output because that's the thing connected to the Solid State Relay and we need to drive voltages out on the Solid State Relay. We have to be able to control voltages. That's why it has to be Output. Pin 22 is Input because the Motion Detector is going to change the voltages on pin 27 and our program is going to look at those voltages and make decisions whether or not motion is detected or not. If you remember, pin 16 is connected directly to pin 18 using a wire, and because of that, we're making pin 16 Output…

Contents