import time
from machine import Pin, PWM

time.sleep(0.1)

# PWM: digital wave square
# but devices take analog
# so, PWM gives feeling of analog voltage to devices
# why not giving analog voltage? impedence/resistance in analog, so digital used
# one cycle of PWM is called duty cycle
# D=(T(ON)/T)*100

# in raspberry pipico for PWM, dont use both of the duplicate pins


# Ques1: Control the intensity of the led using PWM

led = PWM(Pin(0))

led.freq(1000)
# default value of freq in pipico is 1000

# led.duty_u16(65535)
# max duty cycle is 65535, range is [0, 65535]

x=0
while True:
    led.duty_u16(x)
    time.sleep(0.1)
    x+=2000
    if x>65535:
        x=0


#Potentiiometer: gives input in analog form to the microprocessor
#SIG Pin of Potentiometer: should be connected to adc pins(26, 27, 28)  

BOOTSELLED1239USBRaspberryPiPico©2020RP2-8020/21P64M15.00TTT