For the complete documentation index, see llms.txt. This page is also available as Markdown.

begin

使用串口之前,必须先初始化串口

函数原型

void Serial.begin(long speed);

作用

初始化串口,指定串口数据传播速率(波特率)

参数

  • pin

    指定引脚的编号,如: 10 , A0 等。

示例

Serial.begin(9600);             // 一般将波特率设为9600

函数原型

void Serial.begin(long speed, uint8_t config);

参数

  • pin

    指定引脚的编号,如: 10 , A0 等。

  • config

    可选,很少用到,可能的值如下:

    config可选配置

    数据位

    校验位

    停止位

    SERIAL_5N1

    5

    1

    SERIAL_6N1

    6

    1

    SERIAL_7N1

    7

    1

    SERIAL_8N1(默认配置)

    8

    1

    SERIAL_5N2

    5

    2

    SERIAL_6N2

    6

    2

    SERIAL_7N2

    7

    2

    SERIAL_8N2

    8

    2

    SERIAL_5E1

    5

    1

    SERIAL_6E1

    6

    1

    SERIAL_7E1

    7

    1

    SERIAL_8E1

    8

    1

    SERIAL_5E2

    5

    2

    SERIAL_6E2

    6

    2

    SERIAL_7E2

    7

    2

    SERIAL_8E2

    8

    2

    SERIAL_5O1

    5

    1

    SERIAL_6O1

    6

    1

    SERIAL_7O1

    7

    1

    SERIAL_8O1

    8

    1

    SERIAL_5O2

    5

    2

    SERIAL_6O2

    6

    2

    SERIAL_7O2

    7

    2

    SERIAL_8O2

    8

    2

示例

最后更新于