from machine import Pin
import utime
import urandom
# Define the GPIO pins for the LEDs (8 bits)
led_pins = [Pin(0, Pin.OUT), Pin(1, Pin.OUT), Pin(2, Pin.OUT),
Pin(3, Pin.OUT), Pin(4, Pin.OUT), Pin(5, Pin.OUT),
Pin(6, Pin.OUT), Pin(7, Pin.OUT), Pin(8, Pin.OUT)]
#function to generate a random LED pattern
def random_pattern():
pattern = urandom.getrandbits(8)
for i in range(8):
led_pins[i].value((pattern >> i) & 1)
# Main loop for the random Diwali lights effect
while True:
random_pattern()
utime.sleep_ms(500) #Delay for 500 milliseconds