Saltar la navegación

Proyectos Neopixel 3

Dos tiras

#include <Adafruit_NeoPixel.h>
 
#define PIN 3 // input pin Neopixel is attached to
#define PIN_2 2
#define NUMPIXELS      16 // number of neopixels in strip
 
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel pixels_2 = Adafruit_NeoPixel(NUMPIXELS, PIN_2, NEO_GRB + NEO_KHZ800);
int delayval = 200; // timing delay in milliseconds
 
int redColor = 0;
int greenColor = 0;
int blueColor = 0;
 
void setup() {
  // Initialize the NeoPixel library.
  pixels.begin();
  pixels_2.begin();
}
 
void loop() {
  setColor();
 
  for (int i=0; i < NUMPIXELS; i++) {
    // pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
    pixels.setPixelColor(i, pixels.Color(redColor, greenColor, blueColor));
pixels_2.setPixelColor(i, pixels.Color(redColor, greenColor, blueColor));
    // This sends the updated pixel color to the hardware.
    pixels.show();
    pixels_2.show();
 
    // Delay for a period of time (in milliseconds).
    
 
 delay(delayval);
  pixels.setPixelColor(i, pixels.Color(0, 0, 0));
pixels_2.setPixelColor(i, pixels.Color(0, 0, 0));
 
 
}   
 
}
 
// setColor()
// picks random values to set for RGB
void setColor(){
  redColor = random(100, 255);
  greenColor = random(100,255);
  blueColor = random(100, 255);
}