Skip to Content
Hands-On Embedded Programming with C++17
book

Hands-On Embedded Programming with C++17

by Maya Posch
January 2019
Intermediate to advanced
458 pages
10h 35m
English
Packt Publishing
Content preview from Hands-On Embedded Programming with C++17

Motion

The motion module is intended to work with passive infrared (PIR) sensors. These have onboard logic that determine when a trigger point has been reached, at which point they change an interrupt pin into a high signal. We can use this to determine whether a person is in a room, or is walking through a hallway.

Its code looks as follows:

#include "base_module.h" #define GPIO_PIN 0 class MotionModule {    static int pin;    static Timer timer;    static Timer warmup;    static bool motion;    static bool firstLow; public:    static bool initialize();    static bool start();    static bool shutdown();    static void config(String cmd);    static void warmupSensor();    static void readSensor();    static void IRAM_ATTR interruptHandler(); };

Of note here is that we explicitly ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Hands-On RTOS with Microcontrollers

Hands-On RTOS with Microcontrollers

Brian Amos

Publisher Resources

ISBN: 9781788629300Supplemental Content