#define BAUD 115200
// Put setup code here, to run once:
void setup() {
// Serial1 is RP2040's always-ready UART on GP0/1:
Serial1.begin(BAUD);
Serial1.println("Hello! This is the RP2040 UART on GP0/1");
//NOTE: The above will not be seen unless the Wokwi Serial Monitor is switched
// from USB-CDC monitoring to GP0/1 by including this extra line in diagram.json:
// "connections": [ [ "pico:GP0", "$serialMonitor:RX", "", [] ], [ "pico:GP1", "$serialMonitor:TX", "", [] ] ]
// Serial is the USB-CDC "virtual COM port" of the Pi Pico,
// which takes a little longer to ready itself:
Serial.begin(BAUD);
while (!Serial) {
delay(10); // wait for serial port to connect. Needed for native USB
}
// Now you can safely print message:
Serial.println("Hello! This is serial over USB-CDC");
}
void loop() {
// put your main code here, to run repeatedly:
delay(1); // this speeds up the simulation
while (true) {
delay(500);
Serial.println("USB-CDC: Oh, hello there! Hope you're having a nice day :)");
delay(500);
Serial1.println("UART: Hello!"); //NOTE: Will not be seen without updating diagram.json. See notes in setup().
}
}