2.3 Download code Startup automatically

1. Download routine

Looking at the pin diagram of Pico, we know that the control pin of Pico's on-board LED is GPIO25, here we try to control the on-board LED.

image-20220208111551963

After we successfully connected to PICO in the previous section, select Open -- This Computer.

image-20220305114135341

Open the Pico Robot supporting materials -> Appendix -> Course code -> 1. basic course -> 1.On board LED lamp.py.

image-20220305114051985

Click the green Run button, the program starts running, and the Shell window will display %Run -c $EDITOR_CONTENT

image-20220305114313227

At this point, the LED on the PICO board will cycle on and off for one second. If you click the stop button on the menu, or unplug the data cable connected to the computer, the LED will stop blinking.

image-20220305114337316

2. Boot up

The above program can only be run when it is connected to the computer. If you want to unplug the data cable to run, you must write the program file into the PICO.

The provided routines can be set to start at boot by the following methods.

1. Continue to the previous step, in the opened 1.On board LED lamp.py file, select File - Save As.

image-20220305114705015

2. Select Raspberry Pi Pico.

image-20220305114718352

3. Enter main.py in File name, note that the file name of main.py must be used to start, and then click OK.

image-20220305114805285

4. At this point, 1. The onboard LED light.py file becomes [main.py], where [ ] means that the file exists inside the PICO.

image-20220208115357107

5. Press the reset button at this time, or restart the PICO development version, the LED on the board will flash by itself, and there is no need to run the program through the computer.

 

1. After connecting the data cable, select Raspberry Pi Pico

image-20220305114834208

2. At this time, it shows that the development version is busy. According to the prompt, press Ctrl+C

image-20220208115713126

3. At this time, the main.py file is no longer executed, and the program can be run through thonny

image-20220208115741302

image-20220305115041905

image-20220305115113119

Note, please try a few more times if you cannot set it, or re-brush the library file according to Section 2.1 to solve it.