Web Sacosta
Proyectos Neopixel 1 A y B
Neopixel 1A
Random, los colores son al azahar. Puede aparecer cualquier color.
Se ilumina la tira con un color aleatorio que va llenando la tira , esta un tiempo y cambia a otro color.
Solo hay un delay de tiempo de paso entre un led y otro.
#include <Adafruit_NeoPixel.h>
#define PIN 6 // input pin Neopixel is attached to
#define NUMPIXELS 8 // number of neopixels in strip
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, 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();
}
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));
// This sends the updated pixel color to the hardware.
pixels.show();
// Delay for a period of time (in milliseconds).
delay(delayval);
}
}
// setColor()
// picks random values to set for RGB
void setColor(){
redColor = random(0, 255);
greenColor = random(0,255);
blueColor = random(0, 255);
}
Neopixel 1B
#include <Adafruit_NeoPixel.h>
#define PIN 6 // input pin Neopixel is attached to
#define NUMPIXELS 16 // number of neopixels in strip
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, 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();
}
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));
// This sends the updated pixel color to the hardware.
pixels.show();
// Delay for a period of time (in milliseconds).
delay(delayval);
}
}
// setColor()
// picks random values to set for RGB
void setColor(){
redColor = random(100, 255);
greenColor = random(100,255);
blueColor = random(100, 255);
}
Obra publicada con Licencia Creative Commons Reconocimiento Compartir igual 4.0