Created
August 16, 2011 07:17
-
-
Save Arachnid/1148600 to your computer and use it in GitHub Desktop.
sscanf example for decoding colors
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
char data[10]; | |
for(int i = 0; i < 9; i++) | |
data[i] = Serial.read(); | |
data[9] = '\0'; | |
int r, g, b; | |
sscanf(data, "%3x%3x%3x", &r, &g, &b); | |
// r, g and b now contain the color values |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment