AL..ZO / Mbed 2 deprecated Nucleo_read_button

Dependencies:   mbed

main.cpp

Committer:
fralbe
Date:
2017-05-05
Revision:
1:bf9d382dd610
Parent:
0:c9d8fcdda4d0

File content as of revision 1:bf9d382dd610:

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