button (push to on switch) interfacing

Dependencies:   mbed

main.cpp

Committer:
kumaresh
Date:
2015-04-17
Revision:
0:61788d2c2807

File content as of revision 0:61788d2c2807:

#include "mbed.h"
 
DigitalIn mybutton(USER_BUTTON); // user switch available in ST32 nucleo boards
DigitalIn sw1(PC_13);           // refer UM1724 ST nucleo User manual for pin details
DigitalOut myled(LED1);
 
int main() {
  while(1) {
    if (sw1 == 0) {                // or you can use mybutton
      myled = !myled; // Toggle the LED state
      wait(0.2); // 200 ms
    }
  }
}