# L4a- program test lectura canal 0 # La intrarea ADC1 este conectata iesirea un multiplexor # analogic de tip HP4067. L aprimele 10 intrari sint conectate # fotorezistente inseriate cu rezistente de 10K. from machine import Pin, ADC import time import _thread # Conexiuni multiplexor analog fan=_thread.allocate_lock() # fanion mutex s3= Pin(15, Pin.OUT) s2= Pin(14, Pin.OUT) s1= Pin(17, Pin.OUT) s0= Pin(16, Pin.OUT) e= Pin(15, Pin.OUT) ad= ADC(Pin(27, mode=Pin.IN)) # ADC1 # Conexiuni LED -uri cu rezistente de 1 k la Vcc, active in "0". red = Pin(16, Pin.OUT) green= Pin(17, Pin.OUT) blue = Pin(18, Pin.OUT) amber = Pin(19, Pin.OUT) red.high() # stare initiala blue.high() amber.high() green.high() s3.high() s2.low() s1.low() s0.low() e.high() global x0 #x0=0.2 def readx0(): # task actualizare x0 while 1: fan.acquire() # mutex global x0 s3.low() s2.low() s1.low() s0.low() e.low() x0=ad.read_u16()*3.3/65000 e.high() fan.release() # mutex _thread.start_new_thread(readx0,()) while 1: # receptie car. telefon red.low() # aprind time.sleep(0.1) red.high() global x0 green.low() # aprind time.sleep(0.1) green.high() blue.low() # aprind time.sleep(0.1) blue.high() # sting amber.low() # aprind time.sleep(0.1) amber.high() time.sleep(0.1) print(x0) # valoare nivel iluminat fotorezistenta f0