# http://www.robotronix.co.il לימוד רובוטרוניקס
import machine, neopixel
import time
import urandom
from neopixel import NeoPixel
from machine import Pin
from time import sleep
pixels = NeoPixel(Pin(13), 16)
pixels.fill((0, 0, 0))
pixels.write()
n = 15 # number of LEDs
pin = 13 # Pin connected to the LED data pin
np_leds = neopixel.NeoPixel(machine.Pin(pin), n)
def random_color():
return (urandom.getrandbits(8), urandom.getrandbits(8), urandom.getrandbits(8))
while True:
for i in range(n):
np_leds[i] = random_color()
np_leds.write()
time.sleep(1)