Advertisement
Guest User

wave with hue

a guest
Aug 29th, 2014
637
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. //populate a separate array for 'hue mask'
  2.  
  3. void hue_array(){
  4. for(byte i = 0; i < ((NUM_LEDS/2)+ 1); i++){
  5. static byte x = 0;
  6. if(x++ == 5){
  7. hue += 20;
  8. x = 0;
  9. }
  10. temp[i] = hue;
  11. }
  12. }
  13.  
  14. //
  15. void wave_fx(){
  16. static byte middle = NUM_LEDS/2;
  17. currentMillis = millis();
  18. if(currentMillis - previousMillis >= 10) {
  19. count++;
  20. if (count == 255) {
  21. count = 0;
  22. }
  23. for (byte i = 0; i <= middle; i++){
  24. wave = sin8((millis() / wave_scale) * i);
  25. hue = temp[i]; //populate hue before calling CHSV, otherwise it is destructive to leds[]
  26. leds[i] = CHSV(hue, 255, wave);
  27. }
  28. for(byte i = middle; i <= NUM_LEDS; i++){
  29. leds[i] = leds[NUM_LEDS - i];
  30. }
  31. previousMillis = currentMillis;
  32. LEDS.show();
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement