Rob Keij / Mbed 2 deprecated RGB_Fade

Dependencies:   mbed

Revision:
0:f333a5217736
Child:
1:38f70a2c8f31
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Jun 27 22:40:54 2014 +0000
@@ -0,0 +1,37 @@
+#include "mbed.h"
+
+
+PwmOut r (LED1);
+PwmOut g (LED2);
+PwmOut b (LED3);
+
+
+ float RGB_Colour[3];
+
+
+ int main()  {
+    r.period(0.001);
+    
+    while(1) {
+
+        RGB_Colour[0] = 1.0;   // start with red
+        RGB_Colour[1] = 0.0;
+        RGB_Colour[2] = 0.0;  
+
+  for (int DEC_Colour = 0; DEC_Colour < 3; DEC_Colour += 1) {
+    int INC_Colour = DEC_Colour == 2 ? 0 : DEC_Colour + 1;
+ 
+     // cross-fade the two colours.
+    for(float i = 0.0; i < 1.0 ; i += 0.001) {
+      RGB_Colour[DEC_Colour] -= 0.001;
+      RGB_Colour[INC_Colour] += 0.001;     
+ 
+      r = 1.0-RGB_Colour[0];
+      g = 1.0-RGB_Colour[1];
+      b = 1.0-RGB_Colour[2];
+      
+      wait(0.001);
+    }
+  }
+ }
+}