Dimming the leds one by one. After each led is fully lit it will go out, the next will start ligthing up.

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
LNSound
Date:
Tue Oct 12 19:24:07 2010 +0000
Child:
1:20d55e2596f5
Commit message:

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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Oct 12 19:24:07 2010 +0000
@@ -0,0 +1,107 @@
+/*
+ *  mbed demo code
+ *
+ *   This code has been made for a training session. 
+ *
+ *  Copyright (c) 2010 NXP Semiconductors Japan
+ *  Released under the MIT License: http://mbed.org/license/mit
+ *
+ *  revision 1.0  18-Feb-2010   1st release
+ */
+
+#include "mbed.h"
+
+PwmOut led[] = { LED4, LED3, LED2, LED1 };
+
+int main() {
+
+    unsigned char rate, rate2, rate3, rate4;
+
+    rate=0;
+    rate2=0;
+    rate3=0;
+    rate4=0;
+    while ( 1 )
+    {
+    
+       
+             led[ 0 ]    = rate / 255.0;
+             led[ 1 ]    = rate2 / 255.0;
+             led[ 2 ]    = rate3 / 255.0;
+             led[ 3 ]    = rate4 / 255.0;
+    
+    
+               // wait( 0.01 );
+                
+                if (rate <255 &&  rate2 ==0 && rate3==0 && rate4==0)
+                {
+                rate++;
+                }
+                if (rate == 255)
+                 rate=0;
+                 
+                 
+                 if (rate == 0 &&  rate2 <255 && rate3==0 && rate4==0)
+                {
+                rate2++;
+                }
+                if (rate2 == 255)
+                 rate2=0;
+                 
+                    if (rate == 0 &&  rate2 ==0 && rate3 <255 && rate4==0)
+                {
+                rate3++;
+                }
+                if (rate3 == 255)
+                 rate3=0;
+                 
+                if (rate ==0 &&  rate2 ==0 && rate3==0 && rate4<255)
+                {
+                rate4++;
+                }
+                if (rate4 == 255)
+                 rate4=0;
+                
+        
+        
+     /*    for (unsigned char rate3=0; rate<=255; rate3++)
+        {
+         led[ 1 ]    = rate3 / 255.0;
+      //   wait( 0.01 );
+        }
+        
+         for (unsigned char rate4=0; rate<=255; rate4++)
+        {
+         led[ 3 ]    = rate4 / 255.0;
+       //  wait( 0.01 );
+        }
+        
+               
+      //  led[ 2 ]    = rate / 255.0;
+     ////   led[ 1 ]    = 1- (rate / 255.0);
+     //   led[ 3 ]    = 1- (rate / 255.0);
+    //    rate++;
+        
+    */    wait( 0.01 );
+    }
+}
+
+#if 0
+     //   for ( int i = 0, r = rate; i < 4; i++, r += 32 )
+       //     led[ i ]    = ((r  &  0x80) ? (unsigned char)(~r) : (unsigned char)r) / 255.0;
+        
+        rate += 4;
+        
+        wait( 0.01 );
+#endif
+/*
+#if 0
+        led[ 0 ]    = (unsigned char)rate / 255.0;
+        led[ 2 ]    = (unsigned char)rate / 255.0;
+        led[ 1 ]    = 1- ((unsigned char)rate / 255.0);
+        led[ 3 ]    = 1- ((unsigned char)rate / 255.0);
+        rate++;
+        
+        wait( 0.01 );
+#endif
+*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Oct 12 19:24:07 2010 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/49a220cc26e0