我看见Arduino MEGA板子上一共有四个TX RX的接口, 怎么用啊, 用的是这个:
void setup()
{
Serial.begin(19200); //串口0,就是PWM区域里的Pin0和Pin1脚
Serial1.begin(19200); //串口1,即Pin19及Pin18
Serial2.begin(19200); //串口2,即Pin17及Pin16
Serial3.begin(19200); //串口1,即Pin15及Pin14
}
void loop()
{
int val;
val=Serial.read();
Serial.print("Hello world!"); //向串口0发送信息
Serial1.print("Hello world!"); //向串口1发送信息
Serial2.print("Hello world!"); //向串口2发送信息
Serial3.print("Hello world!"); //向串口3发送信息
delay(500);
}
但是他显示:''Serial1' was not declared in this scope'
void setup()
{
Serial.begin(19200); //串口0,就是PWM区域里的Pin0和Pin1脚
Serial1.begin(19200); //串口1,即Pin19及Pin18
Serial2.begin(19200); //串口2,即Pin17及Pin16
Serial3.begin(19200); //串口1,即Pin15及Pin14
}
void loop()
{
int val;
val=Serial.read();
Serial.print("Hello world!"); //向串口0发送信息
Serial1.print("Hello world!"); //向串口1发送信息
Serial2.print("Hello world!"); //向串口2发送信息
Serial3.print("Hello world!"); //向串口3发送信息
delay(500);
}
但是他显示:''Serial1' was not declared in this scope'