Back to Parent

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

#define PIXEL_PIN D2
#define PIXEL_COUNT 3
#define PIXEL_TYPE WS2812

Adafruit_NeoPixel strip = Adafruit_NeoPixel(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE);
uint32_t n = strip.Color(0, 0, 0);
uint32_t R = strip.Color(200, 0, 0);
uint32_t G = strip.Color(0, 200, 0);
int redPin = D3;
int greenPin = D4;

void setup() 
{
    strip.begin();
    for( int i = 0; i < strip.numPixels(); i++ )
        {
        strip.setPixelColor(i, R); 
        }
    strip.show();
    pinMode(redPin, INPUT_PULLUP);
    pinMode(greenPin, INPUT_PULLUP);
}

void loop() 
{

  int redState = digitalRead( redPin );
  int greenState = digitalRead ( greenPin );
  if(redState == LOW)
  {
     strip.setPixelColor( 2, R);
     strip.show();
  }
  if(greenState == LOW)
  {
     strip.setPixelColor( 2, G);
     strip.show();
  }
delay(500);
}
Click to Expand

Content Rating

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

0