A digital input monitoring implementation with an interrupt.

main.cpp

Committer:
sarahmarshy
Date:
2016-09-26
Revision:
0:501aab314b48

File content as of revision 0:501aab314b48:

#include "mbed.h"
 
InterruptIn button(SW1);
DigitalOut led(LED1);
DigitalOut heartbeat(LED2);
 
void toggle() {
    led = !led;
}
 
int main() {
    button.rise(&toggle);  // call toggle function on the rising edge
    while(1) {           // wait around, interrupts will interrupt this!
        heartbeat= !heartbeat;
        wait(0.25);
    }
}