from machine import Pin,PWM,ADC
from utime import sleep
LDR = ADC(28)
pwm = PWM(Pin(15))
print("Hello, Pi Pico!")
# The frequency (pwm.freq) tells Raspberry Pi Pico how often to switch
# the power between on and off for the LED.
pwm.freq(1000)
# For Raspberry Pi Pico in MicroPython,
# this can range from 0 to 65025.
# 65025 would be 100% of the time,
# so the LED would stay bright.
# A value of around 32512 would indicate that
# it should be on for half the time.
# Have a play with the pwm.freq() values and the pwm.duty_u16 values,
# as well as the length of time for the sleep,
# to get a feel for how you can adjust
# the brightness and pace of the pulsing LED.
while True:
value = LDR.read_u16()
print(value)
pwm.duty_u16(value)
if value < 5000:
print("low")
sleep(0.001)
elif value > 5000:
print("better")
sleep(0.001)