from machine import ADC, Pin
from time import sleep
photoPIN = 26
# handle all the (few) operations required to read light intensity
# convert it into a percentage
def readLight(photoGP):
photoRes = ADC(Pin(26))
light = photoRes.read_u16()
light = round(light/65535*100,2)
return light
while True:
print("light: " + str(readLight(photoPIN)) +"%")
sleep(1) # set a delay between readings