Book Image

BeagleBone By Example

By : Pei JIA, Jayakarthigeyan Prabakar, Alexander Hiam
Book Image

BeagleBone By Example

By: Pei JIA, Jayakarthigeyan Prabakar, Alexander Hiam

Overview of this book

BeagleBone is a low cost, community-supported development platform to develop a variety of electronic projects. This book will introduce you to BeagleBone and get you building fun, cool, and innovative projects with it. Start with the specifications of BeagleBone Black and its operating systems, then get to grips with the GPIOs available in BeagleBone Black. Work through four types of exciting projects: building real-time physical computing systems, home automation, image processing for a security system, and building your own tele-controlled robot and learn the fundamentals of a variety of projects in a single book. By the end of this book, you will be able to write code for BeagleBone in order to operate hardware and impart decision-making capabilities with the help of efficient coding in Python.
Table of Contents (17 chapters)
BeagleBone By Example
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
Index

Motion detection using PIR sensors


Now that we know how a PIR sensors works, let's go ahead and hook it up with our BeagleBone board to detect motion.

First of all, take three berg wires and connect the PIR sensor to the BeagleBone board, as per the following circuit diagram:

As shown in the preceding circuit diagram, connect the PIR sensor's Vcc to the 5V pin on the BeagleBone board, the output pin of PIR to GPIO60 on the BeagleBone board, and the ground pins on both with each other.

Then, we will turn on the BeagleBone board and log in to the Linux shell to start coding it.

Create a new Python program using sudo nano TestPIR.py:

Type in the code shown in the following screenshot:

Once you have typed in the code, you can go ahead and save it using Ctrl + X.

Have a look at the comments in the code to get an idea of how it works. We are setting up GPIO_60 as INPUT PIN, reading the RISING edge from the output coming from the PIR sensor, and printing out text saying Movement Detected every time we...