LED output example l by Soft PWM.

Dependencies:   SoftPWM mbed

Fork of pwmLED by Takemasa Nakamura

Files at this revision

API Documentation at this revision

Comitter:
komaida424
Date:
Thu Oct 24 15:52:28 2013 +0000
Parent:
0:b3a395ee08f3
Commit message:
LED output example by SoftPWM

Changed in this revision

SoftPWM.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show diff for this revision Revisions of this file
mbed.lib Show annotated file Show diff for this revision Revisions of this file
diff -r b3a395ee08f3 -r 155dd5b24708 SoftPWM.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SoftPWM.lib	Thu Oct 24 15:52:28 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/komaida424/code/SoftPWM/#7918ce37626c
diff -r b3a395ee08f3 -r 155dd5b24708 main.cpp
--- 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);
+            }
         }
+    }
 }
diff -r b3a395ee08f3 -r 155dd5b24708 mbed.bld
--- a/mbed.bld	Sun Oct 17 05:53:09 2010 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/e6be4cd80aad
diff -r b3a395ee08f3 -r 155dd5b24708 mbed.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.lib	Thu Oct 24 15:52:28 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/#9c8f0e3462fb