呼吸灯效果。

Dependencies:   mbed-src

Revision:
1:5eb1442dc90a
Parent:
0:6d1e0c347dc3
--- a/main.cpp	Thu Nov 19 03:38:51 2015 +0000
+++ b/main.cpp	Thu Nov 19 03:50:29 2015 +0000
@@ -8,24 +8,24 @@
     
     wait(0.1);
     // specify period first
-    led.pulsewidth_us(100);      // 4 second period
-    led.write(0);      // 50% duty cycle, relative to period
+    led.period_us(100);      // 4 second period
+    led.write(1);      // 50% duty cycle, relative to period
     //led = 0.5f;          // shorthand for led.write()
     //led.pulsewidth(2);   // alternative to led.write, set duty cycle time in seconds
-    wait(0.1);
+    //wait(0.1);
     while(true){
         p = 1.00;
         for(n=0;n<101;n++){
             p = p - 0.01;
             led.write(p);
-            wait(0.1);
+            wait(0.02);
         }
+        
         for(n=0;n<101;n++){
             p = p + 0.01;
             led.write(p);
-            wait(0.1);
+            wait(0.02);
         }
-        
-        wait(2);
+        wait(0.2);
     }
 }
\ No newline at end of file