PyRaspBeta

← All practice problems

Raspberry Pi practice problem · LEDs & PWM

Dice face

MediumBudget $12Python · gpiozero

Seven LEDs arranged like the pips on a die:

 TL      TR
 ML  C   MR
 BL      BR

TL GPIO5, TR GPIO6, ML GPIO13, C GPIO19, MR GPIO26, BL GPIO20, BR GPIO21.

Show the faces 1, 2, 3, 4, 5, 6, each for 0.5 s starting at 0 s, then start again at 1 (at 3.0 s), forever. Use the usual die layout:

facelit
1C
2TL, BR
3TL, C, BR
4TL, TR, BL, BR
5TL, TR, C, BL, BR
6TL, TR, ML, MR, BL, BR

Tip: keep a table of 7-tuples, one per face, and feed it to an LEDBoard.

More in LEDs & PWM