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>

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

// IMPORTANT: Set pixel COUNT, PIN and TYPE
#define PIXEL_PIN D2
#define PIXEL_COUNT 8
#define PIXEL_TYPE WS2812

Adafruit_NeoPixel strip = Adafruit_NeoPixel(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE);
// Our button wired to D0
int switchPin = D3;
int brightness = 0;
int increment = 255;
int takePeriod = 3 * 1000;


void setup(){

pinMode(switchPin , INPUT_PULLUP); // sets pin as input

strip.begin();
}

// store the brightness in a new variable

void loop(){
    int switchState = digitalRead( switchPin );
	if( switchState == HIGH ){
        delay(takePeriod);
        uint32_t c = strip.Color(255,0,0); // red
        for( int i = 0; i < strip.numPixels(); i++ ){
            strip.setPixelColor(i, c); // set a color 
            }
        strip.show();
	}else{
	    uint32_t c = strip.Color(255,255,255); // white
        for( int i = 0; i < strip.numPixels(); i++ ){
            strip.setPixelColor(i, c); // set a color 
            }
        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