Example using LED and push button

Fork of mbed-os-example-mbed5-blinky by mbed-os-examples

Committer:
bigg55
Date:
Thu Oct 12 04:56:34 2017 +0000
Revision:
42:ee570b89946e
Parent:
29:0b58d21e87d6
Example Interrupts;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Jonathan Austin 0:2757d7abb7d9 1 #include "mbed.h"
bigg55 42:ee570b89946e 2
bigg55 42:ee570b89946e 3 InterruptIn enable(D0); //Button active LOW
bigg55 42:ee570b89946e 4 DigitalOut led(D1);
bigg55 42:ee570b89946e 5 DigitalOut flash(D2);
bigg55 42:ee570b89946e 6 void flip() {
bigg55 42:ee570b89946e 7 led = !led;
bigg55 42:ee570b89946e 8 }
bigg55 42:ee570b89946e 9
Jonathan Austin 0:2757d7abb7d9 10 int main() {
bigg55 42:ee570b89946e 11 enable.rise(&flip); // attach the address of the flip function to the rising edge
bigg55 42:ee570b89946e 12 while(1) { // wait around, interrupts will interrupt this!
bigg55 42:ee570b89946e 13 flash = !flash;
bigg55 42:ee570b89946e 14 wait(5);
Jonathan Austin 0:2757d7abb7d9 15 }
bigg55 42:ee570b89946e 16
Jonathan Austin 0:2757d7abb7d9 17 }