from machine import Pin
from utime import sleep
from neopixel import NeoPixel
import machine
from machine import ADC
print("Started!")
NUM_LEDS = 16
leds = NeoPixel(Pin(15, Pin.OUT),NUM_LEDS)
potenci = machine.Pin(13, Pin.OUT)
adc = ADC(potenci)
def vaja1(NUM_LEDS, st = 0.1):
while True:
for i in range(NUM_LEDS):
leds[i] = [255,255,255]
leds[i-1] = [0,0,0]
leds.write()
sleep(adc.read()/10000)
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
from random import randrange
from random import randint
def vaja2(NUM_LEDS, st = 0.1):
barva = [randrange(0,255), randrange(0,255), randrange(0,255)]
while True:
for i in range(NUM_LEDS):
mocMutacije = adc.read() / 150
mocMutacije = int(mocMutacije)
print(mocMutacije)
leds[i] = barva
leds.write()
r = (barva[0] + randint(-mocMutacije, mocMutacije))%256
#print(r)
g = (barva[1] + randint(-mocMutacije, mocMutacije))%256
b = (barva[2] + randint(-mocMutacije, mocMutacije))%256
# %256, da nikoli ne pridemo čez rgb vrednost nad 255
barva = [r,g,b]
sleep(st)
vaja2(NUM_LEDS,0.05)