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 red = 0;
int green = 0;
int blue = 0;


void setup() {

  strip.begin();
  strip.show(); // Initialize all pixels to 'off'
  Particle.function("Red", setRed);
  Particle.function("Green", setGreen);
  Particle.function("Blue", setBlue);
}



void loop() {

  uint16_t i;

  for(i=0; i< strip.numPixels(); i++) {
    strip.setPixelColor(i, red, green, blue);//blue
	//strip.setPixelColor(i, 0, 0, 0 );
  }
   strip.show();
// 	delay( 1000 );

}

int setRed(String command){
    int number = atoi(command);
    if(number >=0 && number <= 255){
        red = number;
    }
    return red;
}

int setGreen(String command){
    int number = atoi(command);
    if(number >=0 && number <= 255){
        green = number;
    }
    return green;
}

int setBlue(String command){
    int number = atoi(command);
    if(number >=0 && number <= 255){
        blue = number;
    }
    return blue;
}
Click to Expand

Content Rating

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

0