Solution: Using a Photo-Resistor to Turn On and Off an LED
1 2 3 4 5 6 7 8 910111213141516171819
# Author: J.E. Tannenbaum# Initial Release: 01/22/2022# Night Light LEDfrommachineimportPin,ADCfromtimeimportsleep# Define the pin for the A/D Converterphoto=machine.ADC(26)# Define the pin for the ledled=Pin(16,Pin.OUT)whileTrue:ifphoto.read_u16()>30000:led.on()else:led.off()sleep(.5)