Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
BeagleBone By Example

You're reading from  BeagleBone By Example

Product type Book
Published in Aug 2016
Publisher Packt
ISBN-13 9781785285059
Pages 262 pages
Edition 1st Edition
Languages

Table of Contents (17) Chapters

BeagleBone By Example
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
1. Getting Started with BeagleBone 2. Circuit Fundamentals and GPIO 3. Introduction to Physical Computing Systems 4. Real-time Physical Computing Systems Using BeagleBone 5. Connecting Physical Computing Systems to the Internet 6. Home Automation Using BeagleBone 7. Working with Images Using Computer Vision 8. Home Security Systems Using BeagleBone Black 9. Exploring Robotics 10. Building Your Own Robot 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...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €14.99/month. Cancel anytime}