Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 /*
00002   On KL25Z interrupts only works on ports A and D
00003   Options are: raise and fall
00004 */
00005 
00006 #include "mbed.h"
00007  
00008 InterruptIn button(PTD4); //D3
00009 DigitalOut led(LED1);
00010 DigitalOut flash(LED3);
00011  
00012 
00013 void flip();
00014  
00015 int main() {
00016     button.rise(&flip);  // attach the address of the flip function to the rising edge
00017     
00018     while(1) {           // wait around, interrupts will interrupt this!
00019         flash = !flash;
00020         wait(0.25);
00021     }
00022 }
00023 
00024 void flip() {
00025     led = !led;
00026 }