# Drive an LED at various brightness levels using PWM
from machine import Pin, PWM
led = PWM(Pin(13))
led.freq(1000) # Hz, ranges from 1Hz to 40MHz
led.duty(512) # Fraction, ranges from 0-1024
# Control the position of a servo using PWM
from machine import Pin, PWM
servo = PWM(Pin(23), freq=50)
# For my little SG90 micro-servos,
# 20 is full left, 130 is full right, 90 is about the middle
servo.duty(20)