Everything in this file comes from the Getting started with Raspberry Pi Pico for C/C++ development guide. This file contains all of the same content, just organized into an enumerated list.
Windows menu --> Visual Studio 2019 --> Developer PowerShell for VS 2019pico-sdk. For me, it is C:\Users\vha3\Pico.pico-sdk directory by running the followingC:\Users\vha3\Pico> mkdir testC:\Users\vha3\Pico> cd testpico_sdk_import.cmake file from the external folder in your pico-sdk installation to your test project folder by running:C:\Users\vha3\Pico\test > cp ../pico-sdk/external/pico_sdk_import.cmake .test.c and the other will be CMakeLists.txt. Each is given belowtest.c¶#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¶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)
C:\Users\vha3\Pico\testC:\Users\vha3\Pico\test> mkdir buildC:\Users\vha3\Pico\test> cd buildC:\Users\vha3\Pico\test\build> cmake -G "NMake Makefiles" ..C:\Users\vha3\Pico\test\build> nmakenmake clean before again running nmake.build directory, you will now find the ELF, bin, and uf2 target files for the project. The uf2 target file can be dragged-and-dropped directly onto an RP2040 board attached to your PC via USB, as explained in the next section.This is repeated from this webpage, but included here for completeness.
BOOTSEL button, plug the Pico into a USB port.C:\Users\vha3\Pico\pico-examples\build\blink.uf2 to the Pico, as you would if you were moving a file to a flash drive.