Created
October 11, 2012 23:13
-
-
Save tmpvar/3876228 to your computer and use it in GitHub Desktop.
arduino uno control of of a TLC5971 rgb led driver
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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. 👍