Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Raspberry Pi Sensors
  • Toc
  • feedback
Raspberry Pi Sensors

Raspberry Pi Sensors

By : Rushi Gajjar
4.4 (9)
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
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...
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