Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Fork of Button by
main.cpp@0:cf7f8e884a7e, 2017-08-12 (annotated)
- Committer:
 - rossatmsoe
 - Date:
 - Sat Aug 12 20:05:45 2017 +0000
 - Revision:
 - 0:cf7f8e884a7e
 
Initial version of Button program for MSOE EE2905.
Who changed what in which revision?
| User | Revision | Line number | New contents of line | 
|---|---|---|---|
| rossatmsoe | 0:cf7f8e884a7e | 1 | /* Button | 
| rossatmsoe | 0:cf7f8e884a7e | 2 | |
| rossatmsoe | 0:cf7f8e884a7e | 3 | Reads the USER_BUTTON and flashes LED if pressed. | 
| rossatmsoe | 0:cf7f8e884a7e | 4 | |
| rossatmsoe | 0:cf7f8e884a7e | 5 | based on built-in mbed example Nucleo_read_button | 
| rossatmsoe | 0:cf7f8e884a7e | 6 | modified 12 Aug 2017 by Sheila Ross | 
| rossatmsoe | 0:cf7f8e884a7e | 7 | |
| rossatmsoe | 0:cf7f8e884a7e | 8 | */ | 
| rossatmsoe | 0:cf7f8e884a7e | 9 | |
| rossatmsoe | 0:cf7f8e884a7e | 10 | #include "mbed.h" | 
| rossatmsoe | 0:cf7f8e884a7e | 11 | |
| rossatmsoe | 0:cf7f8e884a7e | 12 | // Declare USER_BUTTON to be a digital input | 
| rossatmsoe | 0:cf7f8e884a7e | 13 | DigitalIn mybutton(USER_BUTTON); | 
| rossatmsoe | 0:cf7f8e884a7e | 14 | |
| rossatmsoe | 0:cf7f8e884a7e | 15 | // Declare LED1 to be a digital output | 
| rossatmsoe | 0:cf7f8e884a7e | 16 | DigitalOut myled(LED1); | 
| rossatmsoe | 0:cf7f8e884a7e | 17 | |
| rossatmsoe | 0:cf7f8e884a7e | 18 | int main() { | 
| rossatmsoe | 0:cf7f8e884a7e | 19 | while(1) { | 
| rossatmsoe | 0:cf7f8e884a7e | 20 | if (mybutton == 0) { // Button is pressed | 
| rossatmsoe | 0:cf7f8e884a7e | 21 | myled = !myled; // toggle LED on/off | 
| rossatmsoe | 0:cf7f8e884a7e | 22 | wait(0.2); | 
| rossatmsoe | 0:cf7f8e884a7e | 23 | } | 
| rossatmsoe | 0:cf7f8e884a7e | 24 | } | 
| rossatmsoe | 0:cf7f8e884a7e | 25 | } | 
| rossatmsoe | 0:cf7f8e884a7e | 26 | 
