LED output example l by Soft PWM.

Dependencies:   SoftPWM mbed

Fork of pwmLED by Takemasa Nakamura

Revision:
1:155dd5b24708
Parent:
0:b3a395ee08f3
--- a/main.cpp	Sun Oct 17 05:53:09 2010 +0000
+++ b/main.cpp	Thu Oct 24 15:52:28 2013 +0000
@@ -1,28 +1,18 @@
-/**
-* \file main.cpp
-* \brief main program
-*/
-
 #include "mbed.h"
 #include "math.h"
-
-// Blink the LED smoothly with PWM. 
-// Also, this project is test of the math function.
+#include "SoftPWM.h"
 
-/**
-* \brief LED to control
-*/
-PwmOut myled(LED1);
-
+SoftPWM led[] = { LED1,LED2,LED3,LED4 };
 
-/**
-* \brief main program
-*/
-int main() {
-    myled.period_ms( 1 );
-    while (1)
-        for ( int i=0; i<360; i+=10 ) {
-            myled = cos( i*2.0*3.14/360 ) * 0.5 + 0.5;
-            wait(0.03);
+int main()
+{
+    for ( int i=0; i<4; i++ ) led[i].period_ms( 1 );
+    while (1)   {
+        for ( int j=0; j<360; j+=10 ) {
+            for ( int k=0; k<4; k++ ) {
+                led[k] = cos( (j+k*90)*2.0*3.14/360 ) * 0.5 + 0.5;
+                wait(0.01);
+            }
         }
+    }
 }