需要的东西:一块面包版、一块raspberry pi pico、红绿黄led灯各一颗、220欧电阻3只、若干线
编程软件:thonny
操作系统:deepin 23
结果展示:
使用raspberry pi pico 制作红绿灯
from machine import Pin
import utime
yellowled=Pin(0,Pin.OUT)#yelow
redled=Pin(2,Pin.OUT)#red
greenled=Pin(1,Pin.OUT)#green
while True:
redled.value(1)
yellowled.value(0)
greenled.value(0)
utime.sleep(9)
redled.value(0)
utime.sleep(0.5)
redled.value(1)
utime.sleep(0.5)
redled.value(0)
utime.sleep(0.5)
redled.value(1)
utime.sleep(0.5)
redled.value(0)
yellowled.value(1)
greenled.value(0)
utime.sleep(0.5)
yellowled.value(0)
utime.sleep(0.5)
yellowled.value(1)
utime.sleep(0.5)
yellowled.value(0)
utime.sleep(0.5)
yellowled.value(1)
utime.sleep(0.5)
greenled.value(9)
redled.value(0)
yellowled.value(0)
utime.sleep(9)
greenled.value(0)
utime.sleep(0.5)
greenled.value(1)
utime.sleep(0.5)
greenled.value(0)
utime.sleep(0.5)
greenled.value(1)
utime.sleep(0.5)
yellowled.value(1)
greenled.value(0)
utime.sleep(0.5)
yellowled.value(0)
utime.sleep(0.5)
yellowled.value(1)
utime.sleep(0.5)
yellowled.value(0)
utime.sleep(0.5)
yellowled.value(1)
utime.sleep(0.5)