Skip to content

Commit a51d4b2

Browse files
committed
fix UART1.
1 parent c0ba8be commit a51d4b2

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed
Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
/*
2-
Serial for UART2
1+
/*
2+
Serial for UART1
33
我们使用“ HardwareSerial ”类进行串行通信。它有一些重要的接口:
44
- HardwareSerial(int uart_nr):这是HardwareSerial的构造函数,其中uart_nr为0,1或2,所以我们有最多3个串行端口。
55
@@ -16,34 +16,34 @@
1616
http://
1717
*/
1818

19-
HardwareSerial Serial2(2);
19+
HardwareSerial Serial1(1);
2020

21-
int8_t U2rxPin = 16;
22-
int8_t U2txPin = 17;
21+
int8_t U1rxPin = 16;
22+
int8_t U1txPin = 17;
2323

2424
char inByte = 0; // incoming serial byte
2525
// the setup routine runs once when you press reset:
2626
void setup()
2727
{
2828
// initialize serial communication at 115200 bits per second:
29-
Serial2.begin(115200,SERIAL_8N1,U2rxPin,U2txPin);
30-
while (!Serial2)
29+
Serial1.begin(115200,SERIAL_8N1,U1rxPin,U1txPin);
30+
while (!Serial1)
3131
{
3232
; // wait for serial port to connect. Needed for native USB port only
3333
}
3434
// serial print hello world.
35-
Serial2.println("Hello world!");
35+
Serial1.println("Hello world!");
3636
}
3737

3838
// the loop routine runs over and over again forever:
3939
void loop()
4040
{
4141
// print out the value if Serial available.
42-
if (Serial2.available() > 0)
42+
if (Serial1.available() > 0)
4343
{
4444
// get incoming byte:
45-
inByte = Serial2.read();
45+
inByte = Serial1.read();
4646
// send back values:
47-
Serial2.write(inByte);
47+
Serial1.write(inByte);
4848
}
4949
}

0 commit comments

Comments
 (0)