How to ?Program Raspberry Pi Pico with Visual Studio Code
This guide will teach you how to use Visual Studio Code to program the Raspberry Pi Pico. An excellent IDE for software development is Visual Studio Code, also known as VS Code. We’ll demonstrate how to install Visual Studio Code on the Raspberry Pi (the host computer), and in a subsequent article, we’ll demonstrate how to do the same for a Windows system (including installation of all the other necessary tools).

Introduction
In all of the prior Raspberry Pi Pico tutorials, we have utilized the Raspberry Pi as the primary host computer and have programmed the Raspberry Pi Pico in C using the terminal. If all your application does is blink an LED or print information on the serial output, then this is acceptable.
However, using a terminal to write and maintain the code for a larger project gets tiresome (at least for beginners). The use of IDEs like Eclipse and VS Code in this situation is crucial.

The Visual Studio Code IDE is advised by the Raspberry Pi Foundation for editing and debugging the code in the Raspberry Pi 4 SBC.
Microsoft created VS Code, also known as Visual Studio Code, which is a program for editing code. It is available for Windows, Linux, and Mac, the three most popular OS platforms. In addition to the standard functions of a code editor, VS Code additionally includes a number of significant features, such as debugging, syntax highlighting, support for plugins, etc.
First, we’ll go over every procedure for setting up Visual Studio Code on the Raspberry Pi host computer. Then, we’ll switch to a Windows system, where a tonne of tools must be downloaded (and installed) before VS Code can be used. So let’s get going.
Installing Visual Studio Code in Raspberry Pi
IMPORTANT NOTE: I strongly advise you to finish the preceding instructions on the Raspberry Pi Pico before installing Visual Studio Code on your Raspberry Pi host computer. Certainly the instructions for “Programming Raspberry Pi Pico with C” and “Program and Debug Raspberry Pi Pico with SWD.”
All of the actions that come after presume that you’ve already installed the required toolchains as described in the earlier lessons.
Open your Raspberry Pi’s browser and navigate to the official VS Code download page first. Download the VS Code ARM.deb package from Linux Downloads by swiping down from the top of the page (64-bit or 32-bit depending on your Raspberry Pi OS).
At the time I was writing this tutorial, it downloaded a file with the name “code 1.54.3-1615805722 armhf.deb” after I chose the.deb package for ARM (not ARM 64).
Double-clicking the downloaded.deb file in the Raspberry Pi’s downloads folder will start the installation of Visual Studio Code.
It’ll request a password. Enter the password for your Raspberry Pi. Simply follow the on-screen instructions for a rather simple installation.
Three extensions for Visual Studio Code must be installed before the programme can be launched. To install each of these extensions one at a time, use the commands below.
code –install-extension marus25.cortex-debug
code –install-extension ms-vscode.cmake-tools
code –install-extension ms-vscode.cpptools
Start Visual Studio Code
Using the terminal command “code,” you can start Visual Studio Code after installing these extensions. But first, make sure that the path for “pico-sdk” has been configured.
export PICO_SDK_PATH=/home/pi/pico/pico-sdk
code
Now, the home page of the VS Code IDE will load.
By choosing the “Explorer” option from the list on the left and clicking “Open Folder,” you can access the “pico-examples” folder in VS Code. By clicking on OK, the file explorer will open and allow you to navigate to the “/home/pi/pico/pico-examples” directory.
The ‘pico-examples’ directory is filled with all the sub-folders, as seen on the left. The CMake plugin for VS Code will be configured by the IDE automatically assuming that you already installed it. You’ll be prompted to configure the “pico-examples” projects by the CMake extension. Then, select “Yes.”
The No Kit Selected option will be located at the bottom of the blue Status Bar if you failed to notice this choice. Toggle that. Select the “GCC for arm-none-eabi” option after that.
The projects can now be built. Once more, select the “Build” option from the status bar’s bottom. You can choose a specific project by selecting [all] next to this “Build” option, or all projects will be built. I choose the “Blink” project to show how it works.
There is an option to set CMake to build in “Debug” or “Release” mode in the status bar. The ‘Debug’ option is pre-selected.
Uploading and Debugging with VS Code
Launch.json, a.json file given by Visual Studio Code, will assist us in uploading the code to the Raspberry Pi Pico and in debugging it. A “settings.json” file is also present, and it configures the CMake extension to function correctly.
These two files must be copied into the “pico-examples” folder. Create the “.vscode” directory in the “pico-examples” directory.
cd ~/pico/pico-examples
mkdir .vscode
Now, add the files “settings.json” and “launch.json” to this directory.
cp ide/vscode/launch-raspberrypi-swd.json .vscode/launch.json
cp ide/vscode/settings.json .vscode/settings.json
Press “Ctrl+Shift+D” to access the Debug Tool bar and upload and debug the code. An option to “Run and Debug” will appear at the top. To build the code, upload it to the Raspberry Pi Pico, and begin a debugging session, press the green play button.
On top, more Debug Control choices will show up. Start the code by pressing the blue play button (continue option in OpenOCD).
Anywhere you like, you can set breakpoints and see if your code reaches them.
Conclusion
I hope all of you understand the process of installing Visual Studio Code in Raspberry Pi and Programming Raspberry Pi Pico with Visual Studio Code or VS Code. We MATHA ELECTRONICS will be back soon with more informative blogs.