Alex Wood / Mbed 2 deprecated PIR_Motion_Example

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 //example using InterruptIn with the input from the PIR motion sensors
00003 InterruptIn alarm(p11);
00004 DigitalOut led(LED1);
00005 DigitalOut flash(LED4);
00006  
00007 void flip() {
00008     led = !led;
00009 }
00010  
00011 int main() {
00012     alarm.mode(PullUp);
00013     wait(2);
00014     alarm.fall(&flip);  // attach the address of the flip function to the falling edge
00015     while(1) {           // wait around, interrupts will interrupt
00016         flash = !flash;
00017         wait(0.25);
00018     }
00019 }