#include <stdio.h>
#include "pico/stdlib.h"
#include "hardware/uart.h"
// Define the UART0 TX and RX pins
#define UART0_TX_PIN 0 // GPIO0 is UART0 TX
#define UART0_RX_PIN 1 // GPIO1 is UART0 RX
int main() {
// Initialize stdio for debugging over USB (optional)
stdio_init_all();
// Print to USB console (optional for debugging)
printf("Starting UART0 Message Print...\n");
// Initialize UART0 with the desired baud rate
uart_init(uart0, 115200);
// Set the GPIO pins for UART0
gpio_set_function(UART0_TX_PIN, GPIO_FUNC_UART); // Configure GPIO0 as UART TX
gpio_set_function(UART0_RX_PIN, GPIO_FUNC_UART); // Configure GPIO1 as UART RX
// Set UART format (optional, default is 8N1)
uart_set_format(uart0, 8, 1, UART_PARITY_NONE); // 8 data bits, 1 stop bit, no parity
// Set FIFO threshold (optional)
uart_set_fifo_enabled(uart0, true);
// Print a message continuously on UART0
const char *message = "Hello from Raspberry Pi Pico W!\n";
while (true) {
// Transmit the message via UART0
uart_puts(uart0, message);
// Add a delay for readability
sleep_ms(1000);
}
return 0;
}