Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Raspberry Pi Sensors
  • Table Of Contents Toc
  • Feedback & Rating feedback
Raspberry Pi Sensors

Raspberry Pi Sensors

By : Rushi Gajjar
4.4 (9)
close
close
Raspberry Pi Sensors

Raspberry Pi Sensors

4.4 (9)
By: Rushi Gajjar

Overview of this book

This book is perfect for hardware enthusiasts who want to develop amazing projects using Raspberry Pi. Some knowledge and experience working with Linux, C, and Python is a plus, but once you're set up to go, you'll be ready to push the creative capabilities of your Raspberry Pi even further.
Table of Contents (10 chapters)
close
close
9
Index

Create a motion detector


We have already set up a piece of software called motion. It detects and captures motion, but that's not fun at all compared to building our own code to capture motion. We will create code that will detect motion and take a decision according to the extent of motion. We will trigger an LED to indicate the decision taken by the RasPi. This code is going to be a bit long, so the explanation is given in comments within the code. However, important information is provided just after the end of the code:

#include <iostream>
#include <cv.h>
#include <highgui.h>
#include <stdio.h>
#include <cctype>
#include <iterator>
#include <unistd.h>
#include <wiringPi.h>
#include "opencv2/highgui/highgui.hpp"
#include <time.h>

using namespace cv;
using namespace std;

int main()
{
/*----Section 1 -----------------Declarations------------------*/
wiringPiSetup();  //To toggle LED, Essential
pinMode(0, OUTPUT); //BCM_GPIO pin 17
CvMemStorage...

Unlock full access

Continue reading for free

A Packt free trial gives you instant online access to our library of over 7000 practical eBooks and videos, constantly updated with the latest in tech

Create a Note

Modal Close icon
You need to login to use this feature.
notes
bookmark search playlist font-size

Change the font size

margin-width

Change margin width

day-mode

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Delete Bookmark

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete

Delete Note

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete

Edit Note

Modal Close icon
Write a note (max 255 characters)
Cancel
Update Note

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY