from machine import pin
import utime
import urandom
#Define the GIO pins for the LEDs (8bits)
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)]
# function to generate a random lED pattern
def random_pattern():
pattern = urandom.getranbits(8)
for i in range(8):
led_pins[i].value((pattern >> i ) & 1)
# Mian loop for the random Diwali lights effect
while True:
random_pattern()
utime.sleep_ms(500) #Delay for 500 miliseconds