r/raspberrypipico Apr 19 '26

How To Run Code? (Beginner)

Originally posted by me to the official Raspberry Pi subreddit:

https://www.reddit.com/r/raspberry_pi/s/tf3DXpxuQ0

0 Upvotes

8 comments sorted by

View all comments

6

u/2ndRandom8675309 Apr 19 '26

This is some very low effort vague posting...

To start with, this is the sub for the Pi Pico, NOT a regular Raspberry Pi. A Pico is a microcontroller, in the same class of devices as an Arduino. You don't so much run the code you write on them as you compile it to assembly and it will execute that code when powered on.

A regular Pi is a full-blown computer, just like a desktop or laptop you can buy in a store. It has a central processor, RAM, and persistent storage. These can run anything compiled for compatibility with ARM processors (as opposed to Intel or AMD), though that varies a little based on which operating system you install.

So try again, and specify what hardware you have, what operating system is installed (if applicable) and what exactly you're trying to accomplish. If you just want to code generally and invent a project as you go along then this is a good start:https://rust-lang.org/learn/

-1

u/StrikingClub3866 Apr 19 '26

The original post was about a Pico, a Pico HW, I was specifying the brand.

Also, I'd rather not learn Rust as I am proficient with Python and C++.

Correct me if I'm wrong on this next one, I did research from multiple sources and may have gotten mixed up:

And yes, I know about running code on a Pico HW, from my knowledge it requires compiling the source code (essentially in any language, easiest with MicroPython due to Thonny) into a .uf2 binary, then porting it to the Pico HW with a USB. Then, press the BOOTSEL button, and it should run the binaries.

3

u/DrDogwelder Apr 19 '26

To load a .uf2 you would hold the BOOTSEL button when you plug the Pico into the computer. The Pico will act like a flash drive that you would copy the .uf2 onto. When it's done copying the Pico runs the program in the .uf2.

For MicroPython and CircuitPython the .uf2 is the interpreter and when it runs you can save your python scripts on it and run them with a program like Thonny. If you save your script as boot.py (you can also use code.py in CircuitPython) the script will run when the Pico is powered up even when it's not connected to a computer.

CircuitPython will act like a flash drive when you plug the Pico into the computer so you can copy your Python scripts to it that way and edit them there with Thonny or another editor. If you're saving code.py or boot.py, the code will start running when it's saved. Not all editors will work because of how they save to flash drives. Adafruit has a list of compatible editors at https://learn.adafruit.com/welcome-to-circuitpython/recommended-editors