Neopixel Brick

Dependencies:   NeoPixel mbed

main.cpp

Committer:
Hinz
Date:
2017-12-11
Revision:
4:1f676d6961e8
Parent:
2:08c13f9a3d5c

File content as of revision 4:1f676d6961e8:

#include "mbed.h"
#include "neopixel.h"

NeoPixel npx(D6,8);

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();
}



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);
    }
        
        
}