Everything in this file comes from the Getting started with Raspberry Pi Pico for C/C++ development guide and Prof. Hunter Adams's project page. This file contains all of the same content, just organized into an enumerated list.
Get your Windows machine setup as described on this webpage.
Open a Developer PowerShell for Visual Studio by navigating to Windows > Visual Studio 2019 > Developer PowerShell for VS 2019
.
Navigate to the directory in which you've installed pico-sdk
.
Create a new directory to house the test project alongside the pico-sdk
directory by running the following:
mkdir test
cd test
pico_sdk_import.cmake
file from the external
folder in your pico-sdk
installation to your test project folder by running:
cp ../pico-sdk/external/pico_sdk_import.cmake .
test.c
to the directory:#include <stdio.h>
#include "pico/stdlib.h"
#include "hardware/gpio.h"
const uint LED_PIN = 25;
int main(){
stdio_init_all();
gpio_init(LED_PIN);
gpio_set_dir(LED_PIN, GPIO_OUT);
while(1){
gpio_put(LED_PIN, 0);
sleep_ms(250);
gpio_put(LED_PIN, 1);
puts("Hello world\n");
sleep_ms(1000);
}
}
CMakeLists.txt
to the same directory:cmake_minimum_required(VERSION 3.13)
include(pico_sdk_import.cmake)
project(test_project)
pico_sdk_init()
add_executable(test test.c)
pico_enable_stdio_usb(test 1)
pico_enable_stdio_uart(test 0)
pico_add_extra_outputs(test)
target_link_libraries(test pico_stdlib)
In the Developer PowerShell for Visual Studio, navigate to your test project repository.
Build by running the following:
mkdir build
cd build
cmake -G "NMake Makefiles" ..
nmake
Note: If, on the second build, you get errors thrown due to syntax in makefiles, run nmake clean
before again running nmake
.
Within the build directory, you will now find a hello_world
directory. You will find directories for each of the other example projects too. These folders will contain the ELF
, bin
, and uf2
target files for each project. The uf2
target file can be dragged-and-dropped directly onto an RP2040 board attached to your PC via USB, as explained here.