Advertisement
Guest User

Untitled

a guest
Mar 30th, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. void loop() {
  2. if(Serial.available()) {
  3. if(Serial.read().first(8) == "0xABCDEF") {
  4. //0xABCDEF is basically my indicator saying "this is for individual LEDs"
  5. //Serial.read() can now be something like 0xABCDEF FF0000 00FF00 0000FF FFFFFF 000000
  6. char* colors[] = Serial.read().split(" ");
  7. colorLED(colors);
  8.  
  9. }
  10. }
  11. }
  12.  
  13. void colorLED(colors) {
  14. for(i = 1; i < colors.length; i++) {
  15. strip.SetPixelColor(i, color[i]);
  16. }
  17. }
  18.  
  19. //hexColor can be "FF0000"
  20. int number = (int)strtol(&hexColor[0], NULL, 16);
  21.  
  22. int r = number >> 16;
  23. int g = number >> 8 & 0xFF;
  24. int b = number & 0xFF;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement