interrupt

Dependencies:   mbed

Committer:
kaushalpkk
Date:
Thu Jun 28 20:18:29 2018 +0000
Revision:
0:7e26160770f8
init!

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kaushalpkk 0:7e26160770f8 1 #include "mbed.h"
kaushalpkk 0:7e26160770f8 2
kaushalpkk 0:7e26160770f8 3 DigitalOut led1(LED1);
kaushalpkk 0:7e26160770f8 4 DigitalOut led2(LED2);
kaushalpkk 0:7e26160770f8 5 InterruptIn button(p30);
kaushalpkk 0:7e26160770f8 6
kaushalpkk 0:7e26160770f8 7 void flip() {
kaushalpkk 0:7e26160770f8 8 wait(0.5);
kaushalpkk 0:7e26160770f8 9 led2 = !led2;
kaushalpkk 0:7e26160770f8 10 printf("Interrupted!!\n");
kaushalpkk 0:7e26160770f8 11 }
kaushalpkk 0:7e26160770f8 12
kaushalpkk 0:7e26160770f8 13 int main() {
kaushalpkk 0:7e26160770f8 14 button.rise(&flip); // attach the address of the flip function to the rising edge
kaushalpkk 0:7e26160770f8 15 while(1) {
kaushalpkk 0:7e26160770f8 16 led1 = !led1;
kaushalpkk 0:7e26160770f8 17 wait(1);
kaushalpkk 0:7e26160770f8 18 }
kaushalpkk 0:7e26160770f8 19 }