feat: Cycle NeoPixel 0 through red, green, blue, and orange
Co-authored-by: aider (gemini/gemini-2.5-pro) <aider@aider.chat>
This commit is contained in:
@@ -11,25 +11,30 @@
|
|||||||
// strandtest example for more information on possible values.
|
// strandtest example for more information on possible values.
|
||||||
Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
|
Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
|
||||||
|
|
||||||
#define DELAYVAL 500 // Time (in milliseconds) to pause between pixels
|
#define DELAYVAL 1000 // Time (in milliseconds) to pause between pixels
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
pixels.begin(); // INITIALIZE NeoPixel strip object (REQUIRED)
|
pixels.begin(); // INITIALIZE NeoPixel strip object (REQUIRED)
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
pixels.clear(); // Set all pixel colors to 'off'
|
// red
|
||||||
|
pixels.setPixelColor(0, pixels.Color(150, 0, 0));
|
||||||
|
pixels.show();
|
||||||
|
delay(DELAYVAL);
|
||||||
|
|
||||||
// The first NeoPixel in a strand is #0, second is 1, all the way up
|
// green
|
||||||
// to the count of pixels minus one.
|
pixels.setPixelColor(0, pixels.Color(0, 150, 0));
|
||||||
for(int i=0; i<NUMPIXELS; i++) { // For each pixel...
|
pixels.show();
|
||||||
|
delay(DELAYVAL);
|
||||||
|
|
||||||
// pixels.Color() takes RGB values, from 0,0,0 up to 255,255,255
|
// blue
|
||||||
// Here we're using a moderately bright green color:
|
pixels.setPixelColor(0, pixels.Color(0, 0, 150));
|
||||||
pixels.setPixelColor(i, pixels.Color(0, 150, 0));
|
pixels.show();
|
||||||
|
delay(DELAYVAL);
|
||||||
|
|
||||||
pixels.show(); // Send the updated pixel colors to the hardware.
|
// orange
|
||||||
|
pixels.setPixelColor(0, pixels.Color(150, 75, 0));
|
||||||
delay(DELAYVAL); // Pause before next pass through loop
|
pixels.show();
|
||||||
}
|
delay(DELAYVAL);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user