Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
10 years ago.
how to communicate between nucleo f411RE and pc through uart
Hello,
i'm trying to establish communication between the Nucleo F411RE board and a pc through uart, I'd like to know how i can read a string from the pc
Question relating to:
1 Answer
10 years ago.
Use the Serial class from mbed.h, with USBRX and USBTX as the RX and TX pins.
include the mbed library with this snippet
/* example code */ #include "mbed.h" Serial pc(USBTX, USBRX); //8N1 char buffer[256]; int main() { buffer[255]=0x00; // ensure a null terminator. while(true) { // read the pending data, and echo it back. if (pc.readable()) { pc.gets(buffer,255); pc.printf("read : %s",buffer); } } }
Thank you, it works fine.
posted by 'Nete Thahe 16 Oct 2015