# ShiftBrite POV

a code for a pov with some shiftbrite (use 5 of them) sorry no video…

``````/************ShiftBrite Functions*************************************************/

#define clockpin 13 // CI
#define enablepin 10 // EI
#define latchpin 9 // LI
#define datapin 11 // DI

#define NumLEDs 8
#define LedHigh 1023

#define Red 0
#define Green 1
#define Blue 2

unsigned int LEDChannels[NumLEDs][3] = {
0};

unsigned int LEDFunction[NumLEDs] = {
0};

boolean GetBool(unsigned int MemUnit,byte Mem){
if((MemUnit >> Mem) & 0x01 == 1)return true;
else return false;
}
void SetBool(unsigned int *MemUnit,byte Mem,boolean Value){
if(Value == true)*MemUnit |= (1UL << Mem);
if(Value == false)*MemUnit &= ~(1UL << Mem);
}

void StartLed(){
pinMode(datapin, OUTPUT);
pinMode(latchpin, OUTPUT);
pinMode(enablepin, OUTPUT);
pinMode(clockpin, OUTPUT);
SPCR = (1<<SPE)|(1<<MSTR)|(0<<SPR1)|(0<<SPR0);
digitalWrite(latchpin, LOW);
digitalWrite(enablepin, LOW);
}

unsigned int LEDChannel(byte LED,byte Color,int Value)
{
int Channel = LEDChannels[LED][Color] & 1023; //Bin : 0000001111111111 so we keep only the number 0 to 1023
int FunctionByte = LEDChannels[LED][Color] & 64512; //1111110000000000 to keep the other data

Value &= 1023;
LEDChannels[LED][Color] = FunctionByte | Value;

return Channel; //return the old value if needed to keep it
}

unsigned int LEDChannel(byte LED,byte Color)
{
return LEDChannels[LED][Color] & 1023;
}

void SB_SendPacket(int SB_CommandMode,int SB_RedCommand,int SB_GreenCommand,int SB_BlueCommand){
if (SB_CommandMode == B01){
SB_RedCommand = 120;
SB_GreenCommand = 100;
SB_BlueCommand = 100;
}
SPDR = SB_CommandMode << 6 | SB_BlueCommand>>4;
while(!(SPSR & (1<<SPIF)));
SPDR = SB_BlueCommand<<4 | SB_RedCommand>>6;
while(!(SPSR & (1<<SPIF)));
SPDR = SB_RedCommand << 2 | SB_GreenCommand>>8;
while(!(SPSR & (1<<SPIF)));
SPDR = SB_GreenCommand;
while(!(SPSR & (1<<SPIF)));
}

void WriteLEDArray(){

int SB_RedCommand;
int SB_GreenCommand;
int SB_BlueCommand;

/*Write to PWM control registers*/
for (int h = 0;h<NumLEDs;h++) {
SB_RedCommand = LEDChannel(h,0);
SB_GreenCommand = LEDChannel(h,1);
SB_BlueCommand = LEDChannel(h,2);
SB_SendPacket(B00,SB_RedCommand,SB_GreenCommand,SB_BlueCommand);
}
delayMicroseconds(15);
digitalWrite(latchpin,HIGH); // latch data into registers
delayMicroseconds(15);
digitalWrite(latchpin,LOW);
/*Write to current control registers*/
for (int z = 0; z < NumLEDs; z++)SB_SendPacket(B01,SB_RedCommand,SB_GreenCommand,SB_BlueCommand);
delayMicroseconds(15);
digitalWrite(latchpin,HIGH); // latch data into registers
delayMicroseconds(15);
digitalWrite(latchpin,LOW);
}

void SetColor(byte StartPos,byte Length,int red,int green,int blue){
for(byte a = StartPos; a < Length + StartPos; a++){
LEDChannel(a,Red,red);
LEDChannel(a,Green,green);
LEDChannel(a,Blue,blue);
}
}
int _[] = {
B00000, B00000, B00000};
int A[] = {
B01111, B10100, B01111};
int B[] = {
B11111, B10101, B01010};
int C[] = {
B01110, B10001, B10001};
int D[] = {
B11111, B10001, B01110};
int E[] = {
B11111, B10101, B10101};
int F[] = {
B11111, B10100, B10100};
int G[] = {
B01110, B10101, B00110};
int H[] = {
B11111, B00100, B11111};
int I[] = {
B00001, B10111, B00001};
int J[] = {
B10000, B10001, B11111};
int K[] = {
B11111, B00100, B01011};
int L[] = {
B11111, B00001, B00001};
int M[] = {
B11111, B01100, B01111};
int N[] = {
B11111, B10000, B01111};
int O[] = {
B01110, B10001, B01110};
int P[] = {
B11111, B10100, B01000};
int Q[] = {
B01111, B10011, B01111};
int R[] = {
B11111, B10100, B01011};
int S[] = {
B01001, B10101, B10010};
int T[] = {
B10000, B11111, B10000};
int U[] = {
B11111, B00001, B11111};
int V[] = {
B11110, B00001, B11110};
int W[] = {
B11110, B00110, B11110};
int X[] = {
B11011, B00100, B11011};
int Y[] = {
B11000, B00100, B11111};
int Z[] = {
B10011, B10101, B11001};

int letterSpace = 6;
int dotTime = 3;

void PrintLetter(int letter[])
{
for(int a = 0; a < 3;a++){
for (int b = 0; b < 5; b++)
{
if(GetBool((letter[a]),b))LEDChannel(b, Red,LedHigh);
else LEDChannel(b, Red,0);
}
WriteLEDArray();
delay(dotTime);
}
// printing the space between the letters
for (int a = 0; a < 5; a++)
{
LEDChannel(a, Red,0);
}
WriteLEDArray();
delay(letterSpace);
}

void setup(){
Serial.begin(38400);
StartLed();
}
void loop(){
while(3 > millis()){ //Wait for millis to be working
}
PrintLetter(S);
PrintLetter(H);
PrintLetter(I);
PrintLetter(F);
PrintLetter(T);
PrintLetter(B);
PrintLetter(R);
PrintLetter(I);
PrintLetter(T);
PrintLetter(E);
PrintLetter(_);
}
``````

Would love to see some pics or videos! Looks like you're just using the ShiftBrites in full-brightness mode to eliminate the choppy effect of PWM? Wondering if the current control registers would help get you a few more colors!