デジットで入手したフルカラーLEDの制御プログラムです。

Dependencies:   mbed

デジットで入手したフルカラーLEDの制御プログラム。

Revision:
1:00a40243c245
Parent:
0:dc9726268dc6
--- a/main.cpp	Mon Jul 15 08:16:02 2013 +0000
+++ b/main.cpp	Mon Jul 15 12:46:16 2013 +0000
@@ -43,13 +43,15 @@
     sendStartFrame();
 }
 
+
 void sendRGB(char rb,char gb ,char bb){
+    /*
     printf("******\n");
     printf("r is %X \n",rb);
     printf("g is %X \n",gb );
     printf("b is %X \n",bb );
     printf("******\n\n");
-    
+    */
     char r = toGrayCode(rb);
     char g = toGrayCode(gb);
     char b = toGrayCode(bb);
@@ -71,15 +73,40 @@
     sendStopFrame();
 }
 
+void sendRGB(int rgb){
+    char r = (char) ((rgb & 0x00FF0000) >> 16);
+    char g = (char) ((rgb & 0x0000FF00) >> 8);
+    char b = (char) ( rgb & 0x000000FF);
+    //printf("r:%X,g:%X,b:%X \n",r,g,b);
+    sendRGB(r,g,b);
+}
+
 
 
 int main() {
+    int rgb =0x000000;
+    int color[] ={
+        0x00000000,
+        0x000000FF,
+        0x0000FF00,
+        0x0000FFFF,
+        0x00FF0000,
+        0x00FF00FF,
+        0x00FFFF00,
+        0x00FFFFFF};
     leds =0x0;
+    int index=0;
     while(1) {
-        
+        //printf("%d\n",index);
         leds=leds+1;
-        sendRGB(0x00,0x00,0xFF);
+        sendRGB(color[index]);
+        index++;    
+        if(index == 8){
+            index = 0;
+            //printf("******");
+        }
         wait(2.0*analog.read());
+        /*
         leds=leds+1;
         sendRGB(0xFF,0x00,0x00);
         wait(2.0*analog.read());
@@ -87,5 +114,6 @@
         sendRGB(0x00,0xFF,0x00);
         wait(2.0*analog.read());
         leds=leds+1;
+        */
     }
 }