Raspberry Pi Pico - 点灯

Raspberry Pi Pico を点灯した。

1
2
3
4
5
6
7
8
9
from machine import Pin, Timer
led = Pin("LED", Pin.OUT)

timer = Timer()

def blink(timer):
    led.toggle()
    
timer.init(freq = 2.5, mode = Timer.PERIODIC, callback = blink)

または

1
2
3
4
5
6
7
8
from machine import Pin
import time
led = Pin("LED", Pin.OUT)

if __name__ == "__main__":
    while True:
        led.toggle()
        time.sleep(1)
Licensed under CC BY-NC-SA 4.0
Built with Hugo
Theme Stack designed by Jimmy