hall effect interupt

Dependencies:   Motor mbed

main.cpp

Committer:
georgezolovick
Date:
2018-04-23
Revision:
0:089307e4191f

File content as of revision 0:089307e4191f:

#include "mbed.h"

Serial pc(USBTX,USBRX);
InterruptIn button(p21);
DigitalOut led(LED1);
BusOut flash(LED2, LED3, LED4);

int counter =0;
 
void flip() {
    led = !led;
    wait(.5);
    counter = counter + 1;
    pc.printf("The count is %d\n",counter);
    led = !led;
}
 
int main() {
    button.rise(&flip);  // attach the address of the flip function to the rising edge
    button.fall(&flip);
    while(1) {           // wait around, interrupts will interrupt this!
        flash = counter;
    }
}