1. Pico:ed-Python Samples
1.1. Add Python Package
Download and unzip the package: lib.zip Install and open it: thonny
Click “Tools” to see more “Options…”
Click “Interpreter” to see more choices by clicking the arrow, and choose Rasperry Pi Pico.
Click the arrow and select “Try to detect port automatically” and click “ok” to confirm.
Cnnect the USB with pico_ed and click “View” to choose “Files”.
Getting in the “Files” folder, open the downloaded and unzipped folder of pico_ed.
Click the right mouse button on the “lib” folder and select “Move to Recyle Bin” to upload the data to pico_ed. After the operation, click “stop” button.
After adding the file, start programming.
Click “File”-”New”
Program and save it in pico_ed.
Enter the name ‘main.py” to the jumped-out column and click “OK” for confirmation.
1.2. Sample Projects
Result
Press button A to light on the LED and button B to turn it off.
Result
Press button A to display 1234567890 on the LEDs screen and button B to display abcdefghijklmnopqrstuvwxyz.
Project 03: The Music Player
from Pico_ed import * #import file
from machine import Pin
while True:
if ButtonA.is_pressed(): #Detect if button A is pressed, if yes, return 1.
music.phonate("1155665-4433221-5544332-5544332-1155665-4433221") #Use this method to play music and the numbers are equivalent to different tones.
#Use method music.phonate("numbered musical notation")
Result
Press button A to play music.
Project 04: Light on the LED connecting to P1.
Hardware Connections
Program
from Pico_ed import * #Program as this way
from machine import Pin
p1 = Pin(pin.P1, Pin.OUT) # Set the pins in output mode, enter with the number of pin.P.
while True:
if ButtonA.is_pressed(): #Detect if button A is pressed, if yes, return 1.
p1.value(1) #P1 pin up
if ButtonB.is_pressed(): #Detect if button B is pressed, if yes, return 1.
p1.value(0) #P1 pin down
Result
Press button A to light on the LED and button B to turn it off.