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.
|
||||
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() {
|
||||
pixels.begin(); // INITIALIZE NeoPixel strip object (REQUIRED)
|
||||
}
|
||||
|
||||
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
|
||||
// to the count of pixels minus one.
|
||||
for(int i=0; i<NUMPIXELS; i++) { // For each pixel...
|
||||
// green
|
||||
pixels.setPixelColor(0, pixels.Color(0, 150, 0));
|
||||
pixels.show();
|
||||
delay(DELAYVAL);
|
||||
|
||||
// pixels.Color() takes RGB values, from 0,0,0 up to 255,255,255
|
||||
// Here we're using a moderately bright green color:
|
||||
pixels.setPixelColor(i, pixels.Color(0, 150, 0));
|
||||
// blue
|
||||
pixels.setPixelColor(0, pixels.Color(0, 0, 150));
|
||||
pixels.show();
|
||||
delay(DELAYVAL);
|
||||
|
||||
pixels.show(); // Send the updated pixel colors to the hardware.
|
||||
|
||||
delay(DELAYVAL); // Pause before next pass through loop
|
||||
}
|
||||
// orange
|
||||
pixels.setPixelColor(0, pixels.Color(150, 75, 0));
|
||||
pixels.show();
|
||||
delay(DELAYVAL);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user