read user button

Dependencies:   mbed

main.cpp

Committer:
ittraining
Date:
2016-05-05
Revision:
1:52e576abcb8a
Parent:
0:c9d8fcdda4d0

File content as of revision 1:52e576abcb8a:

#include "mbed.h"
 
DigitalIn mybutton(PC_13);
DigitalOut myled(LED1);
 
int main() {
  
  
  while(1) {
    if (mybutton == 0) { // Button is pressed
      myled = !myled; // Toggle the LED state
      wait(0.2); // 200 ms
    }
  }
}