Add pwm examples
This commit is contained in:
parent
de247b3354
commit
d803fd81a5
|
@ -0,0 +1,15 @@
|
|||
from machine import Pin
|
||||
from machine import PWM
|
||||
from time import sleep
|
||||
|
||||
led = PWM(Pin(0, Pin.OUT))
|
||||
|
||||
for i in range(-1, 1024, 8):
|
||||
led.duty(i)
|
||||
print(i)
|
||||
sleep(0.1)
|
||||
|
||||
for i in range(1023, -1, -8):
|
||||
led.duty(i)
|
||||
print(i)
|
||||
sleep(0.1)
|
|
@ -0,0 +1,17 @@
|
|||
from machine import Pin
|
||||
from time import sleep
|
||||
|
||||
blue = Pin(0, Pin.OUT)
|
||||
green = Pin(4, Pin.OUT)
|
||||
red = Pin(5, Pin.OUT)
|
||||
|
||||
blue.off()
|
||||
red.on()
|
||||
sleep(1)
|
||||
red.off()
|
||||
green.on()
|
||||
sleep(1)
|
||||
green.off()
|
||||
blue.on()
|
||||
sleep(1)
|
||||
blue.off()
|
Loading…
Reference in New Issue