Connect the Raspberry Pi Pico to one of the USB ports on your Raspberry Pi single-board computer.
 
Note: Thonny IDE is also available on Windows, Mac or Linux computers. 
00:00
After the Raspberry Pi OS has loaded up, click on the Raspberry Pi menu at the top-left hand corner. Navigate to Programming > Thonny Python IDE. 
00:00
With your Pico connected to the Raspberry Pi computer, click on the word 'Python' on the bottom right hand corner of the IDE. This shows the current interpreter, which basically takes the instructions you type in the IDE, and turns them into code that your computer or microcontroller can understand and run. We need to change it so that it uses the correct interpreter for the Raspberry Pi Pico. Several options will be displayed, so look for the one that says MicroPython (Raspberry Pi Pico). If this is done successfully, you will now see the Python Shell display "MicroPython" and "Raspberry Pi Pico". We're now ready to start with programming it!
00:00
Look at the Python Shell, you should see ">>>" symbols. Click just on the right of it and type the following command:

print("Hello, Pico!") 
00:00
Now hit the ENTER key and the program will begin running immediately. It will have responded in the Python Shell with the message, "Hello, Pico!". This happens because the Shell is a direct line to the MicroPython interpreter running your Pico, whose job is to look at the code and interpret it. This is known as 'interactive' mode. So when you press enter, the code is sent through the USB cable to the MicroPython interpreter on the Pico. The interpreter than reads and interprets the code, does what it is told and sends the results back to the USB cable to the Thonny IDE.
00:00
Another way to program it is through script mode. Click on the middle section of the Thonny IDE, and paste the code there. Now what happens if you press enter? It just goes to a new line at line 2. 
00:00
To run the code in script mode, click on the Run button on the top of the IDE. It will prompt you to make a selection, it's asking you if you want to run it on this computer (the Raspberry Pi SBC) or the MicroPython device (which is the Pico). Select the MicroPython device and give the file a descriptive name like Hello_Pico.py. After you are done, click on the OK button.
00:00
Once complete, the program should now run automatically on the Pico. In the Shell, you will see the message appear, "Hello, Pico!"
Congratulations, you've now written your first MicroPython program and ran them in interactive mode as well as script mode.
00:00
main.py
xxx
Terminal
screen /dev/tty.usbmodem0000000000001 115200
>>> led = Pin(25, Pin.OUT)
>>> from machine import Pin
Breadboard
Breadboard
Mark
© 2022 Chick Commerce Pty Ltd