Using photoresistor with 10kohm resistance



  • I'm new here, a few hours ago i've received the fipy and im trying to get a value by the photoresistor,
    the white cable between the photoresistor and resistor goes to pin 16 but i always get the value of 4095.0 even if i cover the photo or point it with the torch
    then the red cable to 3V3 and black to GND
    i've read that maybe this is caused by an incorrect time.sleep()
    can someone pleas help me and explain me whats wrong?
    thank you
    0_1524237636163_img.jpg

    import pycom
    import time
    import machine
    from machine import Pin
    adc = machine.ADC()
    apin = adc.channel(pin='P16')
    def reading():
       avg = 0
       _AVG_NUM = const(100)
       for _ in range (_AVG_NUM):
           avg += apin()
       avg /= _AVG_NUM
       return(avg)
    while True:
        analog_val = reading()
        print(analog_val)
        time.sleep(1)
        pass
    




Pycom on Twitter