hi

Dependencies:   DebouncedInterrupt mbed

Fork of InterruptIn_HelloWorld by mbed official

Committer:
mbed_official
Date:
Fri Feb 15 15:13:19 2013 +0000
Revision:
0:7a20a6aa1f5e
Child:
1:da4614736799
Hello World for InteruptIn

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 0:7a20a6aa1f5e 1 #include "mbed.h"
mbed_official 0:7a20a6aa1f5e 2
mbed_official 0:7a20a6aa1f5e 3 InterruptIn button(p5);
mbed_official 0:7a20a6aa1f5e 4 DigitalOut led(LED1);
mbed_official 0:7a20a6aa1f5e 5 DigitalOut flash(LED4);
mbed_official 0:7a20a6aa1f5e 6
mbed_official 0:7a20a6aa1f5e 7 void flip() {
mbed_official 0:7a20a6aa1f5e 8 led = !led;
mbed_official 0:7a20a6aa1f5e 9 }
mbed_official 0:7a20a6aa1f5e 10
mbed_official 0:7a20a6aa1f5e 11 int main() {
mbed_official 0:7a20a6aa1f5e 12 button.rise(&flip); // attach the address of the flip function to the rising edge
mbed_official 0:7a20a6aa1f5e 13 while(1) { // wait around, interrupts will interrupt this!
mbed_official 0:7a20a6aa1f5e 14 flash = !flash;
mbed_official 0:7a20a6aa1f5e 15 wait(0.25);
mbed_official 0:7a20a6aa1f5e 16 }
mbed_official 0:7a20a6aa1f5e 17 }