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.
11 years, 6 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:
- 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
11 years, 6 months ago.
Hi!
Try to put the line "pc.baud(9600);" inside the function "main".
Good luck!