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.
button.cpp
- Committer:
- Oschofield
- Date:
- 2015-10-20
- Revision:
- 4:5d531bd3c4ea
- Parent:
- 3:8dca756d9804
- Child:
- 7:1e9cd1481e80
File content as of revision 4:5d531bd3c4ea:
#include "button.h" //header file included #include "mbed.h" Button::Button(string s){ if (s == "user"){ pin = new DigitalIn(PA_0); } } bool Button::ifPressed(){ return *pin; } float Button::Duration(){ Timer timer; float duration = 0; timer.reset(); while (duration==0){ while (*pin==1){ timer.start(); } duration= 0.1*timer.read_ms(); timer.stop(); } return duration; }