Back to Parent

// This #include statement was automatically added by the Particle IDE.
#include <neopixel.h>

#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 red = 0;
unsigned long lastFade = 0;
int redPercentage=255;
// int state=HIGH;


void setup() {

  strip.begin();
  strip.show(); 
  Particle.function("Red", setRed);

}


void loop() {
    

	unsigned long now = millis();
// 	int state = HIGH;
if(red == 1){
	    
	    if ((now - lastFade) >= 500) {
		if (redPercentage <= 255 && redPercentage > 0 ) {
			redPercentage = redPercentage - 2.5; 
		}
		lastFade=now;
	    }
	
    for(uint16_t i=0; i < strip.numPixels(); i++) {
        strip.setPixelColor(i, 255, redPercentage, redPercentage);
    }
	strip.show();
	    
}
	
}
  
int setRed(String command){
    int number = atoi(command);
    if(number ==1){
        red = number;
    }
    return red;
}
Click to Expand

Content Rating

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

0