86Duinoハードウェアは、ピン0とピン1にシリアル通信機能を内蔵しています。このネイティブシリアル通信は、チップに内蔵されたUARTと呼ばれるハードウェアを介して行われます。このハードウェアにより、86DuinoのCPUは他のタスクを実行しながらでもシリアル通信を受信できます。
SoftwareSerialライブラリは、86Duinoの他のデジタルピンでシリアル通信を可能にします。ソフトウェアを用いて機能を再現するため、SoftwareSerialという名前が付けられています。パラメータを設定することで、このプロトコルを必要とするデバイス向けに反転信号を設定できます。
このライブラリは 86Duino Coding 103 以降に含まれています。
制限事項
ライブラリには次の既知の制限があります。
- 複数のソフトウェア シリアル ポートを使用する場合、一度にデータを受信できるのは 1 つのポートだけです。
- 86Duino のすべてのピンが変更割り込みをサポートしているわけではないので、RX に使用できるのは 18、19、20、33、34、35、36、37、38、42、43、44 のみです。
- サポートされる最大ボーレートは 19200 bps です。
例
/*
Software serial multple serial test
Receives from the hardware serial, sends to software serial.
Receives from software serial, sends to hardware serial.
The circuit:
* RX is digital pin 42 (connect to TX of other device)
* TX is digital pin 11 (connect to RX of other device)
*/
#include <SoftwareSerial.h>
SoftwareSerial mySerial(42, 11); // RX, TX
void setup()
{
// Open serial communications and wait for port to open:
Serial.begin(57600);
while (!Serial) {
; // wait for serial port to connect.
}
Serial.println("Goodnight moon!");
// set the data rate for the SoftwareSerial port
mySerial.begin(4800);
mySerial.println("Hello, world?");
}
void loop() // run over and over
{
if (mySerial.available())
Serial.write(mySerial.read());
if (Serial.available())
mySerial.write(Serial.read());
}機能
- SoftwareSerial()
- available()
- begin()
- isListening()
- overflow()
- peek()
- read()
- print()
- println()
- listen()
- write()
ライブラリリファレンスホーム
86Duinoリファレンスのテキストは、Arduinoリファレンスを改変したもので、Creative Commons Attribution-ShareAlike 3.0ライセンスに基づいてライセンスされています。リファレンス内のコードサンプルはパブリックドメインとして公開されています。