Skip to content

Instantly share code, notes, and snippets.

@ranisalt
Created May 20, 2015 02:41
Show Gist options
  • Save ranisalt/7c41786dd76343187f05 to your computer and use it in GitHub Desktop.
Save ranisalt/7c41786dd76343187f05 to your computer and use it in GitHub Desktop.
// Configure pings accordingly
enum LED_PINS {
LED_RED = 0,
LED_GREEN = 1,
LED_BLUE = 2,
LED_PWM = 3
};
void writeColor(int color) {
GPIO_Pin red(LED_RED), green(LED_GREEN), blue(LED_BLUE), pwm(LED_PWM);
red.put((char)(color >> 24));
green.put((char)(color >> 16 & 0xFF));
blue.put((char)(color >> 8 & 0xFF));
pwm.put((char)(color & 0xFF));
}
int main() {
writeColor(0xFF00FFFF); // purple, full luminosity
writeColor(0x00FF8080); // aqua, half-luminosity
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment