Back to Parent

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

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

// This #include statement was automatically added by the Particle IDE.
#include <neopixel.h>
// IMPORTANT: Set pixel COUNT, PIN and TYPE
#define PIXEL_COUNT 1
#define PIXEL_PIN D7
#define PIXEL_TYPE WS2812B
Adafruit_NeoPixel strip(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE);

int redValue = 255; // Full brightness for an ANODE RGB LED is 0, and off 255
int greenValue = 255; // Full brightness for an ANODE RGB LED is 0, and off 255
int blueValue = 255; // Full brightness for an ANODE RGB LED is 0, and off 255</td>
int photoCellPin = A0;
int photoCellReading = 0;
//int button = D4;
int piezo = A5;
int b = 0;
void setup()
{

 //  pinMode(button, INPUT_PULLUP);
  // Set up our NEOPIXEL RGB Pin pins for output
  strip.begin();	


}

void loop()
{

    setRGBColor( 255,255,255);    // set it to white
	
   // b = digitalRead(button);
   b = analogRead(piezo); //read value from piezo sensor
   if ( b >800)// checkvalue from piezo sensor
{
  setRGBColor( 255,0,0);    // set it to red 
  delay( 3000);
}

    if(analogRead(photoCellPin) > 600) 
{
    setRGBColor( 255,0,0);    // set it to red
		delay( 100);						// wait 2 seconds
    setRGBColor( 255,255,0);    // set it to yellow
		delay( 100);						// wait 2 seconds
    setRGBColor( 255,127,0);    // set it to orange
		delay( 100);						// wait 2 seconds
    setRGBColor( 255,0,255);    // set it to magenta
		delay( 100);						// wait 2 seconds
    setRGBColor( 0,255,0);    // set it to green
		delay( 100);						// wait 2 seconds
    setRGBColor( 0,255,0);    // set it to green
		delay( 100);						// wait 2 seconds
    setRGBColor( 255,105,50);    // set it to red
		delay( 100);						// wait 2 seconds
    setRGBColor( 255,55,110);    // set it to yellow
		delay( 100);						// wait 2 seconds
    setRGBColor( 55,127,30);    // set it to orange
		delay( 100);						// wait 2 seconds
    
}

}

// Note that 
// Full brightness for an ANODE RGB LED is 0, and off 255
// So we set our RGB values to be 255 - value (invert them)

void setRGBColor( int r, int g, int b ){

  redValue = r;
  greenValue = g;
  blueValue = b;

  strip.setPixelColor(0, redValue, greenValue, blueValue);
  strip.show();
}
Click to Expand

Content Rating

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

0