Allows normal IO pins to be used as bit bashed UART pins. Pins used for RX must support interrupts, only 1 NeoSWSerial UART can receive at a time.
NeoSWSerial is better that SoftwareSerial for reliability and and lower CPU impact. However, NeoSWSerial is limited to only 9600, 19200, 31250, and 38400 baud,
Resources
https://www.arduino.cc/en/Reference/SoftwareSerial
http://arduiniana.org/libraries/newsoftserial/
Example Usage
#include <NeoSWSerial.h>
NeoSWSerial mySerial(8, 7); // RX=pin #, TX=pin #
void audio_init (void)
{
//Set the baud rate for the NeoSWSerial port
mySerial.begin(9600);
mySerial.println("Hello, world?");
}
void tx_packet (void)
{
byte tx_data[4];
mySerial.write("Hello");
tx_data[0] = 0x00;
tx_data[1] = 0x01;
tx_data[2] = 0x02;
tx_data[3] = 0x03;
mySerial.write(&tx_data[0], 4);
}
Receiving Data
Note you can define unlimited software serial ports, but only 1 can be set to receive at a time.
//Enable RX (will occur in background using irq's)
mySerial.listen();
//....
while (mySerial.available() > 0)
{
char data = mySerial.read();
}
//or:
char data = mySerial.read();
if (data != -1)
{
//Byte received
}
