Menu
CoddyTech

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 off

Like 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 icon

Challenge

Easy

Flash 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
}
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Displays and Sensors

Practice on your own: Arduino playground