PyRaspBeta

← All practice problems

Raspberry Pi practice problem · Displays

Chained pixels

HardBudget $22Python · gpiozero

Chain a NeoPixel stick and a NeoPixel ring on one data line: GPIO18 → stick DIN, stick DOUT → ring DIN, both on 5 V. Drive all 20 LEDs from one NeoPixel object: the stick is pixels 0–7, the ring is pixels 8–19.

Update everything every 0.25 s, on the quarter seconds (0, 0.25, 0.5 s…). At time t:

  • stick: the first min(floor(t), 8) pixels green (0, 255, 0), the rest off — a progress bar that grows by one each second
  • ring: exactly one pixel lit, blue (0, 0, 255): ring pixel floor(t × 4) % 12 — a spinner going round once every 3 s

More in Displays