PyRaspBeta

← All practice problems

Raspberry Pi practice problem · Displays

Rainbow wheel

MediumBudget $14Python · gpiozero

A NeoPixel ring (12 LEDs, DIN on GPIO18, 5 V) shows a rainbow that turns.

  • in frame f, pixel i shows the hue ((i + f) % 12) / 12 at full saturation and value, scaled to 0–255 (colorsys.hsv_to_rgb(h, 1, 1), each channel × 255)
  • frame f appears at f × 0.5 s (frame 0 at the start), forever

So pixel 0 is red in frame 0, green (hue 4/12) in frame 4 and blue (hue 8/12) in frame 8.

More in Displays