Neopixel Brick

Dependencies:   NeoPixel mbed

Revision:
4:1f676d6961e8
Parent:
2:08c13f9a3d5c
diff -r 14dc18aceca9 -r 1f676d6961e8 main.cpp
--- a/main.cpp	Wed Jun 07 13:16:58 2017 +0000
+++ b/main.cpp	Mon Dec 11 12:55:19 2017 +0000
@@ -1,21 +1,45 @@
 #include "mbed.h"
+#include "neopixel.h"
+
+NeoPixel npx(D6,8);
 
-//------------------------------------
-// Hyperterminal configuration
-// 9600 bauds, 8-bit data, no parity
-//------------------------------------
+void setByte(uint8_t bits, uint32_t color)
+{
+    for (int i=0; i<8; i++) 
+        if (bits & 1 << i)
+            npx.setColor(i,color);
+        else
+            npx.setColor(i,0);    
+    npx.show();
+}
 
-Serial pc(SERIAL_TX, SERIAL_RX);
 
-DigitalOut myled(LED1);
 
-int main()
-{
-    int i = 1;
-    pc.printf("Hello World !\n");
-    while(1) {
-        wait(1);
-        pc.printf("This program runs since %d seconds.\n", i++);
-        myled = !myled;
+int main() {
+    int i;
+  
+    for (i=0; i<8; i++)
+     npx.setColor(i,0x00ff00);    
+    npx.show();
+    wait(5.0);
+
+    npx.setColor(0,0xff0000);    
+    npx.setColor(1,0x00ff00);    
+    npx.setColor(2,0x0000ff);    
+    npx.setColor(3,0xffff00);    
+    npx.setColor(4,0x00ffff);    
+    npx.setColor(5,0xff00ff);    
+    npx.setColor(6,0xffffff);    
+    npx.setColor(7,0x1f1f1f);
+    npx.show();    
+    wait(5.0);
+    
+    char* text = "INFORMATIK";
+ 
+    while(*text) {
+        setByte(*text++,0xff0000);
+        wait(1.0);
     }
+        
+        
 }