LED Lighting in Breathing & Marquee Mode (Live Mode)
LED Lighting in Breathing & Marquee Mode (Live Mode)
In the example, the cyberpi and math libraries are used to control the lighting of the LEDs on CyberPI, enabling them to scroll their colors while changing their brightness.
import math
import random
import cyberpi
from time import sleep
cyberpi.led.show(“r g b y c”)
# Set the initial light colors for the LEDs of CyberPi
count = 0
while True:
cyberpi.led.set_bri(math.sin(count / 4) * 50 + 52)
# Use the trigonometric function of the math library to enable the lightness of the LEDs to change periodically.
cyberpi.led.move(1)
# Use the LED scrolling function of the cyberpi library to enable the colors of the LEDs to scroll.
count += 1
sleep(0.1)