This example shows how to use interruptions to simply turn on/off a led.
Fork of mbed-os-example-mbed5-blinky by
main.cpp
00001 #include "mbed.h" 00002 00003 00004 //Define outputs 00005 00006 DigitalOut blue(LED3); 00007 00008 00009 //Define interrupt inputs 00010 00011 InterruptIn button(SW2); //interrupcion para el boton 2 00012 00013 00014 void BlinkLed (){ 00015 blue=!blue; 00016 } 00017 00018 00019 int main() 00020 { 00021 __enable_irq(); //Enable Interrupts 00022 00023 blue=0; //initialize output 00024 00025 button.rise(&BlinkLed); //The ISR activates with rising edge of button and activate the function. 00026 00027 00028 while(1) 00029 { 00030 // Write your code 00031 00032 } 00033 }
Generated on Mon Jul 18 2022 01:16:54 by
1.7.2
Johan Quiroga
