atuline

Just a cheap and nasty fadeup hack.

Nov 7th, 2018
462
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. #include <FastLED.h>
  2.  
  3. #define NUM_LEDS 32
  4.  
  5. #define DATA_PIN 12
  6. #define CLOCK_PIN 11
  7.  
  8. CRGB leds[NUM_LEDS];
  9.  
  10. uint8_t ledctr = 0; //
  11.  
  12.  
  13. void setup() {
  14. delay(1000);
  15. Serial.begin(57600);
  16. FastLED.addLeds<APA102, DATA_PIN, CLOCK_PIN>(leds, NUM_LEDS);
  17. }
  18.  
  19. void loop() {
  20. // FadeUp();
  21.  
  22. newFade();
  23. FastLED.show();
  24. delay(33);
  25. } // loop()
  26.  
  27.  
  28. void FadeUp(){
  29. for (int i=0; i<255; i=i+5) {
  30. leds[ledctr].g = i;
  31. delay(10);
  32. FastLED.show();
  33. }
  34.  
  35. if (ledctr++ > NUM_LEDS-1) {
  36. ledctr = 0;
  37. FastLED.clear();
  38. }
  39. }
  40.  
  41.  
  42. void newFade() {
  43.  
  44. for (int i=0; i<9; i++) {
  45. leds[ledctr].g = pow(2,i)-1;
  46. delay(100);
  47. FastLED.show();
  48. }
  49.  
  50. if (ledctr++ > NUM_LEDS-1) {
  51. ledctr = 0;
  52. FastLED.clear();
  53. }
  54. }
Add Comment
Please, Sign In to add comment