Add initial project files and implement LED control via UART commands
This commit is contained in:
29
myws2812.py
Normal file
29
myws2812.py
Normal file
@@ -0,0 +1,29 @@
|
||||
# Bibliotheken laden
|
||||
from machine import Pin
|
||||
from neopixel import NeoPixel
|
||||
from time import sleep_ms
|
||||
|
||||
# GPIO-Pin für WS2812
|
||||
pin_np = 28
|
||||
|
||||
# Anzahl der LEDs
|
||||
leds = 3
|
||||
|
||||
# Helligkeit: 0 bis 255
|
||||
brightness = 128
|
||||
|
||||
# Geschwindigkeit (Millisekunden)
|
||||
speed = 200
|
||||
|
||||
# Initialisierung WS2812/NeoPixel
|
||||
np = NeoPixel(Pin(pin_np, Pin.OUT), leds)
|
||||
|
||||
# Wiederholung (Endlos-Schleife)
|
||||
while True:
|
||||
for i in range (leds):
|
||||
# Nächste LED einschalten
|
||||
np[i] = (brightness, brightness, 0)
|
||||
np.write()
|
||||
sleep_ms(speed)
|
||||
# LED zurücksetzen
|
||||
np[i] = (0, 0, 0)
|
||||
Reference in New Issue
Block a user