SoftwareSerial Library

The 86Duino hardware has built-in support for serial communication on pins 0 and 1. The native serial support happens via a piece of hardware (built into the chip) called a UART. This hardware allows 86Duino’s CPU to receive serial communication even while working on other tasks.

The SoftwareSerial library allows serial communication on other digital pins of the 86Duino, using software to replicate the functionality (hence the name “SoftwareSerial”). A parameter enables inverted signaling for devices which require that protocol.

This library is included in 86Duino Coding 103 and later.

Limitations

The library has the following known limitations:

  • If using multiple software serial ports, only one can receive data at a time.
  • Not all pins on 86Duino support change interrupts, so only the following can be used for RX: 18, 19, 20, 33, 34, 35, 36, 37, 38, 42, 43, 44.
  • The maximum supported baudrate is 19200 bps.

Example

/*
  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());
}

Functions

SoftwareSerial()
available()
begin()
isListening()
overflow()
peek()
read()
print()
println()
listen()
write()


Libraries Reference Home

The text of the 86Duino reference is a modification of the Arduino reference, and is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.