Skip to content

Commit 56eba20

Browse files
committed
fix: 修改软串口例程中的引脚
1 parent 8ed27c5 commit 56eba20

File tree

2 files changed

+15
-16
lines changed

2 files changed

+15
-16
lines changed

libraries/SoftwareSerial/examples/SoftwareSerialExample/SoftwareSerialExample.ino

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,24 @@
55
Receives from software serial, sends to hardware serial.
66
77
The circuit:
8-
* RX is digital pin 10 (connect to TX of other device)
9-
* TX is digital pin 11 (connect to RX of other device)
8+
* RX is PA0 (connect to TX of other device)
9+
* TX is PA1 (connect to RX of other device)
1010
1111
created back in the mists of time
12-
modified 25 May 2012
13-
by Tom Igoe
12+
modified 19 Aug 2023
13+
by HalfSweet
1414
based on Mikal Hart's example
1515
1616
This example code is in the public domain.
1717
1818
*/
1919
#include <SoftwareSerial.h>
2020

21-
SoftwareSerial mySerial(10, 11); // RX, TX
21+
SoftwareSerial mySerial(PA0, PA1); // RX, TX
2222

2323
void setup() {
2424
// Open serial communications and wait for port to open:
25-
Serial.begin(57600);
25+
Serial.begin(115200);
2626
while (!Serial) {
2727
; // wait for serial port to connect. Needed for native USB port only
2828
}

libraries/SoftwareSerial/examples/TwoPortReceive/TwoPortReceive.ino

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,30 +13,29 @@
1313
1414
The circuit:
1515
Two devices which communicate serially are needed.
16-
* First serial device's TX attached to digital pin 10(RX), RX to pin 11(TX)
17-
* Second serial device's TX attached to digital pin 8(RX), RX to pin 9(TX)
16+
* First serial device's TX attached to PA0(RX), RX to pin PA1(TX)
17+
* Second serial device's TX attached to PA4(RX), PA5(TX)
1818
1919
2020
created 18 Apr. 2011
21-
modified 19 March 2016
22-
by Tom Igoe
21+
modified 19 Aug 2023
22+
by HalfSweet
2323
based on Mikal Hart's twoPortRXExample
2424
2525
This example code is in the public domain.
2626
2727
*/
2828

2929
#include <SoftwareSerial.h>
30-
// software serial #1: RX = digital pin 10, TX = digital pin 11
31-
SoftwareSerial portOne(10, 11);
30+
// software serial #1: RX = PA0, TX = PA1
31+
SoftwareSerial portOne(PA0, PA1);
3232

33-
// software serial #2: RX = digital pin 8, TX = digital pin 9
34-
// on the Mega, use other pins instead, since 8 and 9 don't work on the Mega
35-
SoftwareSerial portTwo(8, 9);
33+
// software serial #2: RX = PA4, TX = PA5
34+
SoftwareSerial portTwo(PA4, PA5);
3635

3736
void setup() {
3837
// Open serial communications and wait for port to open:
39-
Serial.begin(9600);
38+
Serial.begin(115200);
4039
while (!Serial) {
4140
; // wait for serial port to connect. Needed for native USB port only
4241
}

0 commit comments

Comments
 (0)