WS2801 LED’s on Arduino uno, shiftOut

Following on from a video tutorial, here’s some code.
(The video isĀ https://www.youtube.com/watch?v=PNQ8R1Ptvs4)

//create arrays
int RED[8];
int GREEN[8];
int BLUE[8];
//
//pin map
int clockpin = 2;
int datapin = 3;
//
//setup code
void setup()
{
pinMode(clockpin, OUTPUT);
pinMode(datapin, OUTPUT);
for (int i=0;i<8;i++)
{
RED[i]=0;
BLUE[i]=0;
GREEN[i]=0;
}
}
//
void updatestring()
{
for(int i=0;i<8;i++)
{
shiftOut(datapin, clockpin, MSBFIRST, BLUE[i]);
shiftOut(datapin, clockpin, MSBFIRST, GREEN[i]);
shiftOut(datapin, clockpin, MSBFIRST, RED[i]);
}
}
//
void loop()
{
for(int i=0;i<8;i++)
{
RED[i]=255;GREEN[i]=255;BLUE[i]=255;
updatestring();
RED[i]=0;GREEN[i]=0;BLUE[i]=0;
delay(300);
}
}

1 thought on “WS2801 LED’s on Arduino uno, shiftOut

Comments are closed.