Turn Weact Blackpill to uart-to-usb device by arduino

Step 1:

Check your Tools menu and make sure your settings look exactly like this:

  • Board: Generic STM32F4 series
  • Board Part Number: BlackPill F411CE (Do not pick the generic F411 options)
  • U(S)ART support: Enabled (generic 'Serial')
  • USB support: CDC (generic 'Serial' supersede U(S)ART)
//PA10 (RX) and PA9 (TX)

void setup() {
  // Initialize USB CDC
  Serial.begin(9600); 
  
  // Initialize Hardware UART
  Serial1.begin(9600); 
}

void loop() {
  // Read from USB and send to UART
  if (Serial.available()) {
    Serial1.write(Serial.read());
  }
  
  // Read from UART and send to USB
  if (Serial1.available()) {
    Serial.write(Serial1.read());
  }
}