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, 10 months ago.
How to change speed (baudrate) of USBSerial communication?
The default speed (baudrate) of mbed LPC1768 for the sample in the web site is 19200. I did not find a place for changing it in the codes. Could anyone help me? Thnaks.
Question relating to:
1 Answer
10 years, 10 months ago.
#include "mbed.h"
DigitalOut myled1(LED1);
Serial pc(USBTX, USBRX); //use these pins for serial coms.
int main(void) {
pc.baud(115200);//Set baudrate here.
pc.printf("Hello World!\r\n");
while(1) {
myled1 = 1;
wait(0.1);
myled1 = 0;
wait(0.1);
}
}
Try this in main pc.baud(115200); or any other baudrate.
posted by David Fletcher 14 Mar 2015this does not work. the compiler returns this error: use of undeclared identifier 'pc'
posted by Ghasem Pasandi 15 Mar 2015Then add this Serial pc(USBTX, USBRX); outside of int main(void).. Or see my answer below.
posted by David Fletcher 15 Mar 2015