from machine import Pin
from neopixel import NeoPixel
import time
# --- SETUP ---
# LED Strip configuratie
LED_PIN = 32 # De pin waar de Data-in van de strip aan hangt
NUM_LEDS = 8 # Aantal LEDs op de strip
np = NeoPixel(Pin(LED_PIN, Pin.OUT), NUM_LEDS)
# Knop configuratie (voor Oefening 8)
# We gebruiken hier Pin 25 als voorbeeld voor de schakelaar
# We gebruiken PULL_UP: knop niet ingedrukt = 1 (High), ingedrukt = 0 (Low)
button = Pin(25, Pin.IN, Pin.PULL_UP)
# --- HULPFUNCTIES ---
def clear_leds():
"""Zet alle LEDs uit"""
for i in range(NUM_LEDS):
np[i] = (0, 0, 0)
np.write()
# --- OEFENINGEN ---
print("Oefening 7: Loop van 1 naar 8 (Optimaler)")
clear_leds()
for i in range(NUM_LEDS):
# 1. Zet huidige pixel AAN
np[i] = (255, 0, 0)
# 2. Stuur data
np.write()
# 3. Wacht
time.sleep_ms(500)
# 4. Zet huidige pixel UIT in geheugen
np[i] = (0, 0, 0)
# Bevestig dat de laatste pixel uit gaat
np.write()