Øvingsoppgave fra rep time... med interrupt ..bruker ikke polling i main loop
Dependencies: mbed
main.cpp
- Committer:
- madmonkeyman82
- Date:
- 2015-11-20
- Revision:
- 0:d1e23b548735
File content as of revision 0:d1e23b548735:
#include "mbed.h" DigitalOut led(LED1); //InterruptIn button(PB_3); InterruptIn button(PC_13); static int ButtonPressed = 0; void interruptFall() { ButtonPressed = 1; } void interruptRise() { ButtonPressed = 0; } int main() { // Init the ticker with the address of the function (toggle_led) to be attached and the interval (100 ms) button.mode(PullDown); button.rise(&interruptRise); button.fall(&interruptFall); button.enable_irq(); while (true) { if (ButtonPressed) { led=1; } else { led=!led; wait(1); } } }