Fill and Clear the Ring
Part of the Displays and Sensors section of Coddy's Arduino journey. Lesson 14 of 24.
Two calls set every pixel at once:
ring.fill(blue); // every pixel blue
ring.clear(); // every pixel offLike setPixelColor(), they only change the colours stored in the board's memory. The ring keeps showing what it was last sent until you call show(). So after clear(), the ring stays lit until the next show().
This is on purpose: you can change many pixels and send them in one go, so the whole ring changes at the same moment instead of one pixel at a time.
Challenge
EasyFlash the whole ring:
- every pixel blue for 500 ms
- then every pixel off for 500 ms
- again and again
Press Run, then Check.
Try it yourself
#include <Adafruit_NeoPixel.h>
// 16 pixels, data on pin 6
Adafruit_NeoPixel ring(16, 6, NEO_GRB + NEO_KHZ800);
uint32_t blue = ring.Color(0, 0, 255);
void setup() {
ring.begin();
}
void loop() {
// the whole ring blue for 500 ms, then off for 500 ms
}
This lesson includes a short quiz. Start the lesson to answer it and track your progress.
All lessons in Displays and Sensors
1Seven-Segment Displays
Seven-Segment DisplayDigit Patterns in BytesCount on the DisplayCountdown to ZeroDice Roller3NeoPixels
Your First NeoPixelColours on a Pixel RingFill and Clear the RingPixel ChaserNeoPixel BrightnessRainbow RingPractice on your own: Arduino playground