Back to Parent

#include <neopixel.h>


#define PIXEL_PIN D2
#define PIXEL_COUNT 16
#define PIXEL_TYPE WS2812
 
Adafruit_NeoPixel strip = Adafruit_NeoPixel(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE);
int fadeInRed(String red);

unsigned long startMillis;
unsigned long currentMillis;
    const unsigned long period = 10;
    int brightness = 0;       //initial brightness
    byte increment = 3;



void setup() {
    strip.begin();
    strip.show(); // Initialize all pixels to 'off'
    
    Particle.function("red", fadeInRed);
    // startMillis = millis();
    


}

void loop() {
//     currentMillis = millis();  //get the current time

//   if (currentMillis - startMillis >= period) {
//     brightness += increment;    //will wrap round from 255 to 0 because brightness is an unsigned data type
//     startMillis = currentMillis;  //IMPORTANT to save the start time of the current LED brightness


}

  int fadeInRed(String red) {

      uint16_t i;
      int brightness = brightness + 5;
      uint32_t r = strip.Color(brightness, 0, 0);
      
    for(int b = 0; b<255; b+=3){
        uint32_t r = strip.Color(b, 0, 0);
    
       for(i=0; i<strip.numPixels(); i++){
      strip.setPixelColor(i,r);
       }
  strip.show();
  delay(3000);
    }
    return 1;
}
Click to Expand

Content Rating

Is this a good/useful/informative piece of content to include in the project? Have your say!

0