material preparing
RTL8722DM x 1, LED x 1, resistance (220 ohms) x 1
examples
PWM pulse width modulation control output pulse cycle to achieve control of the LED brightness and motor, below is how we use leds to show PWM to real do,
Connection PA_26 LED to the positive and resistor in series with the then GND connected to the LED the cathode, as shown in figure
Then, copy the following code line by line to REPL and observation, the LED will slowly gradient bright,
From the machine import Pin, PWM
The import time
P=PWM (pin="PA_26")
# 0 duty cycle thus output 0
P.w rite (0.0)
# 10% duty cycle
P.w rite (0.1)
# 50% duty cycle
P.w rite (0.5)
# 100% duty cycle
P.w rite (1.0)