10 years, 11 months ago.

serial objects

hi, i'm a begginer in mbed programming, and i need some help.

when i try to set baudrate, i have some errors:

  1. include "mbed.h"

DigitalOut myled(LED1); Serial pc(USBTX, USBRX); pc.baud(9600); !!!!!!

int main() { char c; char buffer[128];

c = pc.getc();

pc.gets(buffer, 4);

pc.printf("I got '%c' and '%s'\n", c, buffer); }

the errors are: "this declaration has no storage class or type specifier" in file "/main.cpp", Line: 5, Col: 1 "variable "pc" has already been defined" in file "/main.cpp", Line: 5, Col: 1 "expected a ";"" in file "/main.cpp", Line: 5, Col: 2

what i miss?

thanks

Question relating to:

1 Answer

10 years, 11 months ago.

Hi!

Try to put the line "pc.baud(9600);" inside the function "main".

Good luck!