AL..ZO / Mbed 2 deprecated Nucleo_read_button

Dependencies:   mbed

Committer:
fralbe
Date:
Fri May 05 15:40:01 2017 +0000
Revision:
1:bf9d382dd610
Parent:
0:c9d8fcdda4d0
Bottone;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bcostm 0:c9d8fcdda4d0 1 #include "mbed.h"
bcostm 0:c9d8fcdda4d0 2
bcostm 0:c9d8fcdda4d0 3 DigitalIn mybutton(USER_BUTTON);
bcostm 0:c9d8fcdda4d0 4 DigitalOut myled(LED1);
bcostm 0:c9d8fcdda4d0 5
bcostm 0:c9d8fcdda4d0 6 int main() {
fralbe 1:bf9d382dd610 7 bool old=1;
bcostm 0:c9d8fcdda4d0 8 while(1) {
fralbe 1:bf9d382dd610 9 if (mybutton == 0 && old) { // Button is pressed
bcostm 0:c9d8fcdda4d0 10 myled = !myled; // Toggle the LED state
fralbe 1:bf9d382dd610 11 old=0;
fralbe 1:bf9d382dd610 12 //wait(0.2); // 200 ms
bcostm 0:c9d8fcdda4d0 13 }
fralbe 1:bf9d382dd610 14 if(mybutton && !old)
fralbe 1:bf9d382dd610 15 {
fralbe 1:bf9d382dd610 16 old=1;
fralbe 1:bf9d382dd610 17 }
bcostm 0:c9d8fcdda4d0 18 }
bcostm 0:c9d8fcdda4d0 19 }