RPi Pico - Hello World Blink
The following code is intended for use with the official Raspberry Pi Pico SDK for C Language. If you are not using a CEC Robotics computer or laptop, you must first setup the Pi Pico SDK. (I will post a page stating how to do this.)
Create a New Project Using the Pico C Project Template: extract the pico-project-template.zip file in your pico-dev folder. Remember to rename the project folder and also to rename the project in the cMakeLists.txt file. All source files are listed for the project below.
Once you are ready to compile open a bash terminal and navigate to the this project's folder. To compile execute the following bash commands.
cd build
cmake ..
make
Code will be loaded via the USB device bootloader interface by holding the Pi Pico's built in button during power-on.
main.c
#include "pico/stdlib.h"
void main() {
const uint LED_PIN = 25;
gpio_init(LED_PIN);
gpio_set_dir(LED_PIN, GPIO_OUT);
while(1) {
gpio_put(LED_PIN, 1);
sleep_ms(500);
gpio_put(LED_PIN, 0);
sleep_ms(500);
}
}