Last change
on this file since 175 was 175, checked in by ertl-honda, 8 years ago |
ライブラリを Arduino IDE 1.7.9 にupdate
|
File size:
879 bytes
|
Rev | Line | |
---|
[175] | 1 | /*
|
---|
| 2 | Software serial multiple serial test
|
---|
| 3 |
|
---|
| 4 | Receives from the hardware serial, sends to software serial.
|
---|
| 5 | Receives from software serial, sends to hardware serial.
|
---|
| 6 |
|
---|
| 7 | The circuit:
|
---|
| 8 | * RX is digital pin 9 (connect to TX of other device)
|
---|
| 9 | * TX is digital pin 10 (connect to RX of other device)
|
---|
| 10 |
|
---|
| 11 | Note:
|
---|
| 12 | You shouldn't use pin 2
|
---|
| 13 |
|
---|
| 14 | This example code is in the public domain.
|
---|
| 15 |
|
---|
| 16 | */
|
---|
| 17 |
|
---|
| 18 | #include <SoftwareSerial.h>
|
---|
| 19 |
|
---|
| 20 | SoftwareSerial mySerial(9, 10); // RX, TX
|
---|
| 21 |
|
---|
| 22 | void setup()
|
---|
| 23 | {
|
---|
| 24 | // Open serial communications and wait for port to open:
|
---|
| 25 | SerialUSB.begin(115200);
|
---|
| 26 | SerialUSB.println("Goodnight moon!");
|
---|
| 27 |
|
---|
| 28 | // set the data rate for the SoftwareSerial port
|
---|
| 29 | mySerial.begin(9600);
|
---|
| 30 | mySerial.println("Hello, world?");
|
---|
| 31 | }
|
---|
| 32 |
|
---|
| 33 | void loop() // run over and over//
|
---|
| 34 | {
|
---|
| 35 | if (mySerial.available())
|
---|
| 36 | SerialUSB.write(mySerial.read());
|
---|
| 37 |
|
---|
| 38 | if (SerialUSB.available())
|
---|
| 39 | mySerial.write(SerialUSB.read());
|
---|
| 40 | }
|
---|
| 41 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.