Search
https://micropython.org/download/rp2-pico-w/
https://thonny.org/
https://github.com/cpwood/Pico-Go
https://docs.micropython.org/en/v1.9.3/pyboard/
In Thonny command line and write there
from machine import Pin
This will import functionality will import class Pin necessary to control GPIO pins. Intenal LED is connected to pin with symbolic name 'LED', so we can create objected to control this pin. Second parameter of the object constructor of direction of communication.
led = Pin('LED', Pin.OUT)
If the object exists, try following:
pin.on()
Other commands: led.off(), led.toggle()
This version of program uses sleep_ms(). Create script called main.py and save it to the RPi Pico. If the name of the script is as mentioned, code will be executed after restart.
from machine import Pin import time led = Pin('LED', Pin.OUT) while True: time.sleep_ms(1000) led.toggle()
More advanced program uses Timer.
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)