from machine import Pin,ADC
from utime import sleep 
import neopixel 
import random
import time
import dht

NUM_LEDS = 16
nl=16

leds = neopixel. NeoPixel (Pin(15), NUM_LEDS)
leds1 = neopixel. NeoPixel (Pin(2), nl)
gumb=Pin(4, Pin.IN)
sense = dht.DHT22(Pin(17))
pot=ADC(Pin(25))

def convert(x, in_min, in_max, out_min, out_max):
    return (x - in_min) * (out_max - out_min) // (in_max - in_min) + out_min

while True:
    sec=time.time()
    r=random.randrange(0,255)
    if sec%2==0:
        for x in range(NUM_LEDS):
            if x%2==0:
                leds[x]=[255,7,7]
                leds.write()
                
            else:
                leds[x]=[7,7,255]
                leds.write()
                

        
    else:
        for x in range(NUM_LEDS):
            if x%2==0:
                leds[x]=[7,7,255]
                leds.write()
                
            else:
                leds[x]=[255,7,7]
                leds.write()

    for x in range(NUM_LEDS):
        leds1[x]=[99,255,99]
        leds1.write()
        sleep(0.1)
    for x in range(NUM_LEDS):
        leds1[x]=[0,0,0]
        leds1.write()
        sleep(0.1)