17 while (1) {
18 gpio_put(LED_PIN, 0);
19 sleep_ms(250);
20 gpio_put(LED_PIN, 1);
21 puts("Hello World\n");
22 sleep_ms(1000);
23 }
24 }
①
The onboard LED is connected to GP25 on Pico and Pico 2, if
you’re building for Pico W the LED is connected to
CYW43_WL_GPIO_LED_PIN. For more information see the Pico W
blink example in the Pico Examples Github repository.
②
These lines will add strings to the binary visible using
picotool, see Appendix B.
along with a CMakeLists.txt file,
cmake_minimum_required(VERSION 3.13)
include(pico_sdk_import.cmake)
project(test_project C CXX ASM)
set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 17)
pico_sdk_init()
add_executable(test
Ê test.c
)
pico_enable_stdio_usb(test 1)①
pico_enable_stdio_uart(test 1)②
pico_add_extra_outputs(test)
target_link_libraries(test pico_stdlib)
1. This will enable serial output via USB.
2. This will enable serial output via UART.
Then copy the pico_sdk_import.cmake file from the external folder in your pico-sdk installation to your test project folder.
$ cp ../pico-sdk/external/pico_sdk_import.cmake .
You should now have something that looks like this,
$ ls -la
total 24
drwxr-xr-x 5 aa staff 160 6 Apr 10:46 ./
drwxr-xr-x 7 aa staff 224 6 Apr 10:41 ../
-rw-r--r--@ 1 aa staff 394 6 Apr 10:37 CMakeLists.txt
-rw-r--r-- 1 aa staff 2744 6 Apr 10:40 pico_sdk_import.cmake
-rw-r--r-- 1 aa staff 383 6 Apr 10:37 test.c
Getting started with Raspberry Pi Pico-series
Manually Create your own Project 39