mirror of
https://github.com/pybricks/pybricks-api.git
synced 2026-09-11 17:14:41 +00:00
20 lines
542 B
Python
20 lines
542 B
Python
from pybricks.hubs import ExampleHub
|
|
from pybricks.parameters import Icon
|
|
from pybricks.tools import wait
|
|
|
|
# Initialize the hub.
|
|
hub = ExampleHub()
|
|
|
|
# Turn the hub light off (optional).
|
|
hub.light.off()
|
|
|
|
# Create a list of intensities from 0 to 100 and back.
|
|
brightness = list(range(0, 100, 4)) + list(range(100, 0, -4))
|
|
|
|
# Create an animation of the heart icon with changing brightness.
|
|
hub.display.animate([Icon.HEART * i/100 for i in brightness], 30)
|
|
|
|
# The animation repeats in the background. Here we just wait.
|
|
while True:
|
|
wait(100)
|