New example. Initial version.

Committer:
CSTritt
Date:
Fri Oct 01 03:03:36 2021 +0000
Revision:
110:22b71c32c5e1
Parent:
109:b061f9830736
Child:
111:956b1c606b66
First Mbed v. 5 version.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
CSTritt 107:61b9c99a4e27 1 /*
CSTritt 110:22b71c32c5e1 2 Project: 21_TimerTest1_v5
CSTritt 109:b061f9830736 3 File: main.cpp
CSTritt 110:22b71c32c5e1 4
CSTritt 110:22b71c32c5e1 5 Explores timer behavior. Each loop takes about 24 mS. Most of this time is
CSTritt 110:22b71c32c5e1 6 likely spent doing the serial output.
CSTritt 110:22b71c32c5e1 7
CSTritt 110:22b71c32c5e1 8 Last modified 9/30/21 by C. S. Tritt (v. 1.0)
CSTritt 107:61b9c99a4e27 9 */
Jonathan Austin 0:2757d7abb7d9 10 #include "mbed.h"
CSTritt 108:eee3167b25b4 11
CSTritt 110:22b71c32c5e1 12 // Construct a timer object.
CSTritt 110:22b71c32c5e1 13 Timer myTimer;
CSTritt 110:22b71c32c5e1 14 // Construct a transmit only serial connection over our USB.
CSTritt 110:22b71c32c5e1 15 Serial pc(USBTX, NC, 9600);
CSTritt 110:22b71c32c5e1 16
CSTritt 109:b061f9830736 17 int main()
CSTritt 109:b061f9830736 18 {
CSTritt 110:22b71c32c5e1 19 myTimer.start(); // Start the timer.
CSTritt 110:22b71c32c5e1 20
CSTritt 110:22b71c32c5e1 21 for (int i = 1; i <= 20; i++) { // Main loop.
CSTritt 110:22b71c32c5e1 22 // Save the time on timer.
CSTritt 110:22b71c32c5e1 23 float current_time = myTimer.read();
CSTritt 110:22b71c32c5e1 24 // Send the time as text via the serial port.
CSTritt 110:22b71c32c5e1 25 pc.printf("Time %f seconds.\n",current_time );
CSTritt 108:eee3167b25b4 26 }
CSTritt 108:eee3167b25b4 27 }