[Serial]
Description
Sets the data rate in bits per second (baud) for serial data transmission. For communicating with the computer, use one of these rates: 300, 600, 1200, 2400, 4800, 9600, 14400, 19200, 28800, 38400, 57600, or 115200. You can, however, specify other rates – for example, to communicate over pins 0 and 1 with a component that requires a particular baud rate. The maximum baud rate supported by 86Duino is 6000000 (6Mbps).
An optional second argument configures the data, parity, and stop bits. The default is 8 data bits, no parity, one stop bit.
And an optional third argument selects the full-duplex and half-duplex modes. The default is the full-duplex mode.
Syntax
All boards:
Serial.begin(speed)Serial1.begin(speed)Serial.begin(speed, config)Serial1.begin(speed, config)Serial1.begin(speed, mode)Serial1.begin(speed, config, mode)
86Duino One specific:
Serial2.begin(speed)Serial3.begin(speed)Serial485.begin(speed)Serial2.begin(speed, config)Serial3.begin(speed, config)Serial485.begin(speed, config)Serial2.begin(speed, mode)Serial3.begin(speed, mode)Serial2.begin(speed, config, mode)Serial3.begin(speed, config, mode)
86Duino EduCake specific:
Serial2.begin(speed)Serial3.begin(speed)Serial232.begin(speed)Serial2.begin(speed, config)Serial3.begin(speed, config)Serial232.begin(speed, config)Serial2.begin(speed, mode)Serial3.begin(speed, mode)Serial2.begin(speed, config, mode)Serial3.begin(speed, config, mode)
Parameters
speed: in bits per second (baud) – long. Valid values are:
503006001200240048009600144001920028800384005760011520012500015000020000025000030000050000075000010000001500000200000030000006000000
config: sets data, parity, and stop bits. Valid values are:
SERIAL_5N1SERIAL_6N1SERIAL_7N1SERIAL_8N1(the default)SERIAL_5N2SERIAL_6N2SERIAL_7N2SERIAL_8N2SERIAL_5E1SERIAL_6E1SERIAL_7E1SERIAL_8E1SERIAL_5E2SERIAL_6E2SERIAL_7E2SERIAL_8E2SERIAL_5O1SERIAL_6O1SERIAL_7O1SERIAL_8O1SERIAL_5O2SERIAL_6O2SERIAL_7O2SERIAL_8O2
mode: sets the full-duplex and half-duplex modes. Valid values are:
COM_FullDuplex(the default)COM_HalfDuplex
Returns
nothing
Example
void setup() {
Serial1.begin(9600); // opens serial port, sets data rate to 9600 bps
}
void loop() {}86Duino One/EduCake example:
// Using Serial1, Serial2, Serial3 with different baud rates:
void setup(){
Serial1.begin(38400);
Serial2.begin(19200);
Serial3.begin(4800);
Serial1.println("Hello Serial 1");
Serial2.println("Hello Serial 2");
Serial3.println("Hello Serial 3");
}
void loop() {}See also
- if (Serial)
- available()
- end()
- find()
- findUntil()
- flush()
- parseFloat()
- parseInt()
- peek()
- print()
- println()
- read()
- readBytes()
- readBytesUntil()
- setTimeout()
- write()
- serialEvent()
Language Reference Home
The text of the 86Duino reference is a modification of the Arduino reference and is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.