Read the user button state on the Nucleo board.

Dependencies:   mbed

main.cpp

Committer:
arostm
Date:
6 months ago
Revision:
1:b8f06da41a00
Parent:
0:c9d8fcdda4d0

File content as of revision 1:b8f06da41a00:

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