Skip to content

Instantly share code, notes, and snippets.

@tmpvar
Created October 11, 2012 23:13
Show Gist options
  • Save tmpvar/3876228 to your computer and use it in GitHub Desktop.
Save tmpvar/3876228 to your computer and use it in GitHub Desktop.
arduino uno control of of a TLC5971 rgb led driver
void setup() {
pinMode(2, OUTPUT); // power
pinMode(3, OUTPUT); // SDI
pinMode(4, OUTPUT); // SCK
}
char r[8] = { 0xFF, 0x00, 0x00 };
char g[8] = { 0x00, 0xff, 0x00 };
char b[8] = { 0x00, 0x00, 0xff };
char data[4] = { 0x94, 0x50, 0x0F, 0xFF };
int seq = 0;
void write(byte out) {
shiftOut(3, 4, MSBFIRST, out);
}
void loop() {
digitalWrite(2, HIGH);
int i = 0;
while (i < 8) {
if (i > 3) {
write(r[seq]);
write(r[seq]);
write(g[seq]);
write(g[seq]);
write(b[seq]);
write(b[seq]);
} else {
write(data[i]);
}
i++;
}
delay(1000);
seq++;
if (seq == 3) {
seq = 0;
}
}
@matthewellis
Copy link

Hey the blue and red write commands are in the wrong order, i have forked the code and corrected it.

@NealEhardt
Copy link

I found a bug in the brightness control header; it's not equal across all colors.

I fixed it and posted it here as part of a more thorough example with smooth animation https://gist.github.com/NealEhardt/3be36efb0fccb13acf4c0ad5c839e265

Thank you @tmpvar for posting this and getting me started! Having working code made all the difference while I fixed my buggy circuitry. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment