millis_demo

Dependencies:   mbed millis

Fork of mbed_blinky by Mbed

Files at this revision

API Documentation at this revision

Comitter:
lisper
Date:
Fri Oct 31 08:07:49 2014 +0000
Parent:
6:e8cd76f38fa9
Commit message:
millis_demo

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
millis.lib Show annotated file Show diff for this revision Revisions of this file
diff -r e8cd76f38fa9 -r 4ff2cd962710 main.cpp
--- a/main.cpp	Fri May 09 19:58:03 2014 +0300
+++ b/main.cpp	Fri Oct 31 08:07:49 2014 +0000
@@ -1,12 +1,28 @@
-#include "mbed.h"
+/*
+ *  Copyright:      DFRobot
+ *  license:        GPL
+ *  Author:         lisper (lisper.li@dfrobot.com)
+ *  Date:           2014-10-30
+ *  Description:    example program for millis library
+ */
 
-DigitalOut myled(LED1);
+#include "mbed.h"
+#include "millis.h"
+
 
-int main() {
-    while(1) {
-        myled = 1;
-        wait(0.2);
-        myled = 0;
-        wait(0.2);
+DigitalOut led1(LED1);
+
+int main()
+{
+    startMillis ();     //must call this function if you want use millis ();
+       
+    led1 = 0;
+    uint32_t lastTime = 0;
+    
+    while (1) {
+        if (millis() - lastTime > 1000) {
+            lastTime = millis ();
+            led1 = !led1;
+        }
     }
 }
diff -r e8cd76f38fa9 -r 4ff2cd962710 mbed.bld
--- a/mbed.bld	Fri May 09 19:58:03 2014 +0300
+++ b/mbed.bld	Fri Oct 31 08:07:49 2014 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/
\ No newline at end of file
+http://mbed.org/users/mbed_official/code/mbed/builds/031413cf7a89
\ No newline at end of file
diff -r e8cd76f38fa9 -r 4ff2cd962710 millis.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/millis.lib	Fri Oct 31 08:07:49 2014 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/teams/DFRobot/code/millis/#736e6cc31bcd