Skip to content

Instantly share code, notes, and snippets.

@reconbot
Created July 18, 2014 18:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save reconbot/059859e06db7d71a45eb to your computer and use it in GitHub Desktop.
Save reconbot/059859e06db7d71a45eb to your computer and use it in GitHub Desktop.
oid backlight(unsigned long rgb) {
int r = rgb >> 16 & 0x0000FF;
int g = rgb >> 8 & 0x0000FF;
int b = rgb & 0x0000FF;
r = map(r, 0, 255, 0, brightness);
g = map(g, 0, 255, 0, brightness);
b = map(b, 0, 255, 0, brightness);
// common anode so invert!
r = map(r, 0, 255, 255, 0);
g = map(g, 0, 255, 255, 0);
b = map(b, 0, 255, 255, 0);
analogWrite(R_PIN, r);
analogWrite(G_PIN, g);
analogWrite(B_PIN, b);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment