How to Printf(); Message One Time at Beginning of Raspberry Pi Pico Serial Connection

July 10, 2024, 16:07

nicholaspcoldbloodedcreaturae

Hello. I have an issue with Printf(); on my Raspberry Pi Pico W. I need a prompt printed out at the beginning outside of a while loop. When I try this and have the COM3 port open, it doesn't print, but it moves on to the next part of my code where it scans the input typed into the prompt. Any knowledge on how to fix this? The code is using C++.
c++
#include "stdio.h"
#include "pico/stdlib.h"
#include "pico/cyw43_arch.h"

int main() {
    // Initialize all standard IO
    stdio_init_all();

    // Assign pin as an unsigned integer for GPIO functions
    //const uint led_pin = 25;

    // Initialize LED pin
    //gpio_init(led_pin);
    // Set the GPIO pin as an output
    //gpio_set_dir(led_pin, GPIO_OUT);

    // Boot sequence
    printf("Please select what connection type is being used. USB (1) or LCD (2): ");
    char userInput;
    userInput = getchar();

    if(userInput == '1'){
        main_menu_serial();  // These functions have been excluded from the help post for simplicity sake
        boot_title_serial(); // These functions have been excluded from the help post for simplicity sake
        printf("Done.");
    }
    else if(userInput == '2'){
        printf("\n");
        printf("Why do you do this to me.\n");
    }
    else{
        printf("\n");
        printf("Input is invalid!\n");
    }
}

nicholaspcoldbloodedcreaturae

Nevermind! Issue is resolved now. (I think)