This example shows how to use interruptions to simply turn on/off a led.
Fork of mbed-os-example-mbed5-blinky by
Diff: main.cpp
- Revision:
- 14:0357b4ab5699
- Parent:
- 8:bb09890333fe
--- a/main.cpp Wed Oct 05 05:15:02 2016 +0100
+++ b/main.cpp Mon Mar 26 23:37:33 2018 +0000
@@ -1,13 +1,33 @@
-#include "mbed.h"
+#include "mbed.h"
-DigitalOut led1(LED1);
+
+//Define outputs
+
+DigitalOut blue(LED3);
+
+
+//Define interrupt inputs
+
+ InterruptIn button(SW2); //interrupcion para el boton 2
+
+
+void BlinkLed (){
+ blue=!blue;
+ }
-// main() runs in its own thread in the OS
-// (note the calls to Thread::wait below for delays)
-int main() {
- while (true) {
- led1 = !led1;
- Thread::wait(500);
+
+int main()
+{
+ __enable_irq(); //Enable Interrupts
+
+ blue=0; //initialize output
+
+ button.rise(&blinkLed); //The ISR activates with rising edge of button and activate the function.
+
+
+ while(1)
+ {
+ // Write your code
+
}
-}
-
+}
\ No newline at end of file
Johan Quiroga
