![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Push and hold button to start timer. Release button to print time that the button was held for.
Fork of Timer_HelloWorld by
Revision 2:1e6dc5131b1b, committed 2014-01-07
- Comitter:
- jw2ee
- Date:
- Tue Jan 07 01:16:10 2014 +0000
- Parent:
- 1:272adee7c4ac
- Commit message:
- now with LED light on push, and start up message.
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Tue Jan 07 00:24:41 2014 +0000 +++ b/main.cpp Tue Jan 07 01:16:10 2014 +0000 @@ -1,20 +1,26 @@ #include "mbed.h" DigitalIn button1(PTC3); //button for KL46Z +DigitalOut led1(LED1); Timer t; bool pushed = false; int main() { + led1 =1; + + printf("Time Ready, use button SW1 to start.\r\n"); while(true) { if(!button1 && !pushed) { t.start(); - printf("Timer Started\r\n"); + led1 = 0; + printf("Timer Started!\r\n"); pushed = true; } else if(button1 && pushed) { t.stop(); - printf("The time taken was %f seconds\r\n", t.read()); + led1 = 1; + printf("The time taken was %f seconds.\r\n", t.read()); t.reset(); pushed = false; }