# Creating a new C/C++ Raspberry Pi Pico Project on Windows¶

## Documentation¶

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.

## Creating a new project¶

1. Get your Windows machine setup as described on this webpage.
2. Open a Developer PowerShell for Visual Studio by navigating to Windows menu --> Visual Studio 2019 --> Developer PowerShell for VS 2019
3. Navigate to the directory in which you've installed pico-sdk. For me, it is C:\Users\vha3\Pico.
4. Create a new directory to house the test project alongside the pico-sdk directory by running the following

C:\Users\vha3\Pico> mkdir test
C:\Users\vha3\Pico> cd test

5. Copy the pico_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 .

6. We will add two more files to this directory. One will be called test.c and the other will be CMakeLists.txt. Each is given below

#### test.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()

pico_enable_stdio_usb(test 1)
pico_enable_stdio_uart(test 0)



## Building the project¶

1. In the Developer PowerShell for Visual Studio, navigate to your test project repository. For me, this is C:\Users\vha3\Pico\test
2. Build by running the following:

C:\Users\vha3\Pico\test> mkdir build
C:\Users\vha3\Pico\test> cd build
C:\Users\vha3\Pico\test\build> cmake -G "NMake Makefiles" ..
C:\Users\vha3\Pico\test\build> nmake

3. Note: Error for which I don't yet have an explanation but I do have a solution. If, on the second build, you get errors thrown due to syntax in makefiles, run nmake clean before again running nmake.
4. Within the 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.

## Programming the Pico¶

This is repeated from this webpage, but included here for completeness.

1. While holding down the BOOTSEL button, plug the Pico into a USB port.
2. The Pico will appear as a mass storage device in your file navigator.
3. Drag-and-drop 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.
4. The Pico will automatically reboot, and start running the Blink example, flashing the LED.