Getting started with Raspberry Pi Pico
Chapter 8. Creating your own Project
Go ahead and create a directory to house your test project sitting alongside the
$ ls -la
total 16
drwxr-xr-x
drwx------@ 27 aa
drwxr-xr-x
drwxr-xr-x
$ mkdir test
$ cd test
and then create a
1
#include <stdio.h>
2
#include "pico/stdlib.h"
3
#include "hardware/gpio.h"
4
#include "pico/binary_info.h"
5
6
const
7
8
int
main() {
9
These lines
①
10
bi_decl(bi_program_description("This is a test
will add
11
bi_decl(bi_1pin_with_name(LED_PIN,
strings to the
12
binary visible
13
stdio_init_all();
using
,
picotool
14
see
Appendix
15
gpio_init(LED_PIN);
B.
16
gpio_set_dir(LED_PIN, GPIO_OUT);
17
while
18
19
20
21
22
23
}
24 }
along with a
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
)
Chapter 8. Creating your own Project
7 aa
staff
224
6 Apr 10:41 ./
staff
864
6 Apr 10:41 ../
10 aa
staff
320
6 Apr 09:29 pico-examples/
13 aa
staff
416
6 Apr 09:22 pico-sdk/
file in the directory,
test.c
uint LED_PIN = 25;
(1) {
gpio_put(LED_PIN, 0);
sleep_ms(250);
gpio_put(LED_PIN, 1);
puts("Hello
World\n");
sleep_ms(1000);
file,
CMakeLists.txt
pico-sdk
binary."));①
"On-board
LED"));
directory,
30
Need help?
Do you have a question about the RP2040 and is the answer not in the manual?