LED2 lights on when user button is pressed. For ST nucleo STM32F401

Dependencies:   mbed

Committer:
yousson
Date:
Wed May 14 13:31:32 2014 +0000
Revision:
0:7f1c12137729
ST nucleo button test

Who changed what in which revision?

UserRevisionLine numberNew contents of line
yousson 0:7f1c12137729 1 #include "mbed.h"
yousson 0:7f1c12137729 2
yousson 0:7f1c12137729 3 DigitalIn mybutton(USER_BUTTON);
yousson 0:7f1c12137729 4 DigitalOut myled(LED2);
yousson 0:7f1c12137729 5
yousson 0:7f1c12137729 6 int main() {
yousson 0:7f1c12137729 7 while(1) {
yousson 0:7f1c12137729 8 if (mybutton == 0) { // Button is pressed
yousson 0:7f1c12137729 9 myled = 1; // Toggle the LED state
yousson 0:7f1c12137729 10 }
yousson 0:7f1c12137729 11 else {
yousson 0:7f1c12137729 12 myled = 0; // Toggle the LED state
yousson 0:7f1c12137729 13 }
yousson 0:7f1c12137729 14 }
yousson 0:7f1c12137729 15 }
yousson 0:7f1c12137729 16