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.
Revision 1:d2a607c4341d, committed 2017-09-20
- Comitter:
- CSTritt
- Date:
- Wed Sep 20 02:39:59 2017 +0000
- Parent:
- 0:7931706dde3d
- Commit message:
- Initial version.
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Sun Sep 17 12:37:43 2017 +0000
+++ b/main.cpp Wed Sep 20 02:39:59 2017 +0000
@@ -1,17 +1,13 @@
/*
-Project: WhatTime
+Project: TimerTest1
File: main.cpp
-Uses a timer to display the interval between button press and release.
+Explores timer behavior. Each loop takes about 24 mS.
-Created 12 Aug 2017 by Sheila Ross
-Last modified 9/17/17 by C. S. Tritt
+Last modified 9/17/17 by C. S. Tritt (v. 1.0)
*/
#include "mbed.h"
-
-// Construct a USER_BUTTON digital input.
-DigitalIn myButton(USER_BUTTON);
-
+
// Construct a timer object.
Timer myTimer;
@@ -23,20 +19,11 @@
{
myTimer.start(); // Start the timer.
- while(true) { // Main loop.
- if (myButton == 0) { // Button is pressed (active low).
- // Save the time on timer.
- float current_time = myTimer.read();
-
- // Send the time as text via the serial port.
- pc.printf("Time difference %f seconds.\n",current_time );
-
- // Reset the timer.
- myTimer.reset();
-
- // Wait for the user to release the button.
- while(myButton == 0) {
- }
- }
+ for (int i = 1; i <= 20; i++) { // Main loop.
+ // Save the time on timer.
+ float current_time = myTimer.read();
+
+ // Send the time as text via the serial port.
+ pc.printf("Time %f seconds.\n",current_time );
}
}
\ No newline at end of file