I’ve just uploaded a video showing an update to driving ws2801 strings. This code is for driving them in parallel serial data strings, rather than sequential serial.
#define numleds 32
#define ledsperline 8
#define updatespeed 0
//this code is written for 4 lines of serial data!
int RED[numleds];
int GREEN[numleds];
int BLUE[numleds];
//
//line pin def's
int clockpin1 = 2;
int dataPin1 = 3;
int clockpin2 = 4;
int dataPin2 = 5;
int clockpin3 = 6;
int dataPin3 = 7;
int clockpin4 = 8;
int dataPin4 = 9;
//
//setup stuff
void setup()
{
//pinMode(13, OUTPUT);
pinMode(clockpin1, OUTPUT);
pinMode(dataPin1, OUTPUT);
pinMode(clockpin2, OUTPUT);
pinMode(dataPin2, OUTPUT);
pinMode(clockpin3, OUTPUT);
pinMode(dataPin3, OUTPUT);
pinMode(clockpin4, OUTPUT);
pinMode(dataPin4, OUTPUT);
for (int i = 0; i < numleds; i = i++)
{RED[i]=0;GREEN[i]=0;BLUE[i]=0;}
}
//
void loop() {
for(int l=0;l<32;l++){
RED[l]=l*8+1;BLUE[l]=0;
updatestring();
delay(updatespeed);
}
for(int l=0;l<32;l++){
GREEN[l]=l*8+1;RED[l]=0;
updatestring();
delay(updatespeed);
}
for(int l=0;l<32;l++){
BLUE[l]=l*8+1;GREEN[l]=0;
updatestring();
delay(updatespeed);
}
}
//
//main loop
void loop1() {
//assumption made that blue is on...
//fade to purple
for (int i=0;i<256;i++)
{for (int l=0;l<32;l++)
{RED[l]=i;}
updatestring();
}
//fade to red
for (int i=0;i<256;i++)
{for (int l=0;l<32;l++)
{BLUE[l]=255-i;}
updatestring();
}
//fade to yellow
for (int i=0;i<256;i++)
{for (int l=0;l<32;l++)
{GREEN[l]=i;}
updatestring();
}
//fade to green
for (int i=0;i<256;i++)
{for (int l=0;l<32;l++)
{RED[l]=255-i;}
updatestring();
}
//fade to cyan
for (int i=0;i<256;i++)
{for (int l=0;l<32;l++)
{BLUE[l]=i;}
updatestring();
}
//fade to blue
for (int i=0;i<256;i++)
{for (int l=0;l<32;l++) {GREEN[l]=255-i;}
updatestring();
}
}
//
//update function
void updatestring() {
for (int i =0;i<ledsperline;i++)
{
shiftOut1( BLUE[i],BLUE[i+ledsperline],BLUE[i+2*ledsperline],BLUE[i+3*ledsperline]);
shiftOut1( GREEN[i],GREEN[i+ledsperline],GREEN[i+2*ledsperline],GREEN[i+3*ledsperline]);
shiftOut1( RED[i],RED[i+ledsperline],RED[i+2*ledsperline],RED[i+3*ledsperline]);
}
for (int i =0;i<ledsperline;i++)
{
//shiftOut1(dataPin2, clockpin2, BLUE[i+ledsperline]);
//shiftOut1(dataPin2, clockpin2, GREEN[i+ledsperline]);
//shiftOut1(dataPin2, clockpin2, RED[i+ledsperline]);
}
for (int i =0;i<ledsperline;i++)
{
//shiftOut1(dataPin3, clockpin3, BLUE[i+2*ledsperline]);
//shiftOut1(dataPin3, clockpin3, GREEN[i+2*ledsperline]);
//shiftOut1(dataPin3, clockpin3, RED[i+2*ledsperline]);
}
for (int i =0;i<ledsperline;i++)
{
//shiftOut1(dataPin4, clockpin4, BLUE[i+3*ledsperline]);
//shiftOut1(dataPin4, clockpin4, GREEN[i+3*ledsperline]);
//shiftOut1(dataPin4, clockpin4, RED[i+3*ledsperline]);
}
//eerr
//delay(1);
delayMicroseconds(900);
}
//
//shift out fn
//http://forum.arduino.cc/index.php?topic=45529.0
void shiftOut1(uint8_t val1,uint8_t val2,uint8_t val3,uint8_t val4)
{
uint8_t i;
//
for (i = 0; i < 8; i++) {
digitalWrite(dataPin1, !!(val1 & (1 << (7 - i))));
digitalWrite(dataPin2, !!(val2 & (1 << (7 - i))));
digitalWrite(dataPin3, !!(val3 & (1 << (7 - i))));
digitalWrite(dataPin4, !!(val4 & (1 << (7 - i))));
digitalWrite(clockpin1, HIGH);
digitalWrite(clockpin2, HIGH);
digitalWrite(clockpin3, HIGH);
digitalWrite(clockpin4, HIGH);
digitalWrite(clockpin1, LOW);
digitalWrite(clockpin2, LOW);
digitalWrite(clockpin3, LOW);
digitalWrite(clockpin4, LOW);
}
//
}