Advertisement
Guest User

Untitled

a guest
Mar 18th, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.40 KB | None | 0 0
  1.  
  2. #include <FastLED.h>
  3. #define NUM_LEDS 60                                  
  4. #define DATA_PIN 6  
  5.  
  6. const int buttonPin = 2;     // the number of the pushbutton pin
  7. int buttonState = 0;
  8.  
  9. CRGBArray<NUM_LEDS> leds;
  10. CRGB ledsTemp[NUM_LEDS];  //for holding temporary values
  11.  
  12. void setup() {
  13.   delay (3000);
  14.   FastLED.addLeds<NEOPIXEL,DATA_PIN>(leds, NUM_LEDS);
  15.   Serial.begin(57600);
  16.  
  17.   fill_solid( ledsTemp, 20 ,    CRGB( 0,100,255) );//set range with solid color starting at 0 for 20 pixels
  18.   fill_solid( ledsTemp+20, 20 , CRGB( 100,255,0) );//set range with solid color starting at 20for20 pixels
  19.   fill_solid( ledsTemp+40, 20 , CRGB( 255,0,100) );//set range with solid color starting at 40for 20 pixels
  20.   //leds[5].setRGB( 200, 68, 90);//set specific pixel 5
  21.   //leds[6].setRGB(120, 99, 150); //set specific pixel 6
  22.  
  23.   pinMode(buttonPin, INPUT); // initialize the pushbutton pin as an input:
  24.   }
  25.  
  26. void loop(){
  27.  
  28. buttonState = digitalRead(buttonPin);  // if it is, the buttonState is HIGH:
  29.  
  30. if (buttonState == HIGH) {
  31.   for (int j = 0; j<5; j++){
  32.     for(int i = 0; i < NUM_LEDS-11; i++) {
  33.         leds(i,i+2) = ledsTemp [i] ;        
  34.         leds(i+5,i+10) = ledsTemp[i];
  35.         leds(i+12,i+15) = ledsTemp [i] ;  
  36.  
  37.   Serial.println (i);
  38.   FastLED.show();
  39.   FastLED.delay(100);
  40.   //delay(100);
  41.  
  42.   leds(0,60) = CRGB::Black;        
  43.  
  44.       }
  45.     }
  46.   }
  47.   else {//do nothing
  48.    
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement