Arduino参考

Arduino参考 > Libraries > SoftwareSerial > SoftwareSerial()

SoftwareSerial()

Create an instance of a SoftwareSerial object. Multiple SoftwareSerial objects may be created, however only one can be active at a given moment.

Syntax

SoftwareSerial(rxPin, txPin, inverse_logic)

Parameters

  • rxPin: the pin on which to receive serial data.
  • txPin: the pin on which to transmit serial data.
  • inverse_logic: used to invert the sense of incoming bits (the default is normal logic). If set, SoftwareSerial treats a LOW (0v on the pin, normally) on the RX pin as a 1-bit (the idle state) and a HIGH (5V on the pin, normally) as a 0-bit. It also affects the way that it writes to the TX pin. Default value is false.

Returns

None.

Example

#include <SoftwareSerial.h>

const byte rxPin = 2;
const byte txPin = 3;

// Set up a new SoftwareSerial object
SoftwareSerial mySerial (rxPin, txPin);