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.
main.cpp
- Committer:
- CSTritt
- Date:
- 2021-10-01
- Revision:
- 110:a930767c281c
- Parent:
- 109:b061f9830736
File content as of revision 110:a930767c281c:
/* Project: 21_TimerTest2_v5 File: main.cpp Tests timer peformance. Display new time difference with each button press and release. Differences of 4 or 5 microseconds are typical. Last modified 9/30/21 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; // Construct a transmit only serial connection over our USB. Serial pc(USBTX, NC, 9600); int main() { myTimer.start(); // Start the timer. while(true) { // Main loop. if (myButton == 0) { // Button is pressed (active low). // Save the time on timer. int firstTime = myTimer.read_us(); int secondTime = myTimer.read_us(); // Send the time as text via the serial port. pc.printf("Time difference %i microseconds.\n", secondTime - firstTime ); // Reset the timer. myTimer.reset(); // Wait for the user to release the button. while(myButton == 0) { } } } }