from machine import Pin led = Pin(13, Pin.OUT) led.value(1)
from machine import Pin button = Pin(12, Pin.IN, Pin.PULL_UP) state = button.value()
from machine import Pin, PWM motor = PWM(Pin(14)) motor.freq(1000) motor.duty(512) # 50% duty cycleIn this example, the PWM function is used to create a Pulse-Width Modulation object for controlling a motor (connected to pin 14). The `freq` function is used to set the frequency of the PWM signal, and the `duty` function is used to set the duty cycle (i.e., the percentage of time the signal is "on"). Package library: MicroPython