Temporizador con salida a terminal.

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
jangelgm
Date:
Thu Mar 09 21:43:18 2017 +0000
Commit message:
Temporizador con salida a terminal.

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r ef9a01d503ba main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Mar 09 21:43:18 2017 +0000
@@ -0,0 +1,33 @@
+/* Program Example 9.5: Tests Timer duration, displaying current time values to terminal
+*/
+#include "mbed.h"
+Timer t;
+float s=0; //seconds cumulative count
+float m=0; //minutes cumulative count
+DigitalOut diag(LED1);
+Serial pc(USBTX, USBRX);
+int main()
+{
+    pc.printf("\r\nTimer Duration Test\n\r");
+    pc.printf("-------------------\n\n\r");
+    t.reset(); //reset Timer
+    t.start(); // start Timer
+    while(1) {
+        if (t.read()>=(s+1)) { //has Timer passed next whole second?
+            diag = 1; //If yes, flash LED and print a message
+            wait (0.05);
+            diag = 0;
+            s++ ;
+//print the number of seconds exceeding whole minutes
+            pc.printf("%1.0f seconds\r\n",(s-60*(m-1)));
+        }
+        if (t.read()>=60*m) {
+            printf("%1.0f minutes \n\r",m);
+            m++ ;
+        }
+        if (t.read()<s) { //test for overflow
+            pc.printf("\r\nTimer has overflowed!\n\r");
+            for(;;) {} //lock into an endless loop doing nothing
+        }
+    } //end of while
+}
\ No newline at end of file
diff -r 000000000000 -r ef9a01d503ba mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Mar 09 21:43:18 2017 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/6c34061e7c34
\ No newline at end of file