A digital input monitoring implementation with busy wait.

Committer:
sarahmarshy
Date:
Mon Sep 26 16:22:10 2016 +0000
Revision:
0:c27624b8b1e0
Initial commit. Busy wait button.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sarahmarshy 0:c27624b8b1e0 1 #include "mbed.h"
sarahmarshy 0:c27624b8b1e0 2 #include "rtos.h"
sarahmarshy 0:c27624b8b1e0 3
sarahmarshy 0:c27624b8b1e0 4 DigitalIn button(SW1); // Change to match your board
sarahmarshy 0:c27624b8b1e0 5 DigitalOut led(LED1);
sarahmarshy 0:c27624b8b1e0 6
sarahmarshy 0:c27624b8b1e0 7 #define button_press 0
sarahmarshy 0:c27624b8b1e0 8
sarahmarshy 0:c27624b8b1e0 9 int main() {
sarahmarshy 0:c27624b8b1e0 10 while(1) {
sarahmarshy 0:c27624b8b1e0 11 if(button_press == button){
sarahmarshy 0:c27624b8b1e0 12 led = !led;
sarahmarshy 0:c27624b8b1e0 13 wait(1);
sarahmarshy 0:c27624b8b1e0 14 }
sarahmarshy 0:c27624b8b1e0 15 }
sarahmarshy 0:c27624b8b1e0 16 }