Skip to main content
1 of 2
Siddharth
  • 245
  • 2
  • 4
  • 12

Difference between SoftwareSerial and Serial

From the sample code

#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 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. Needed for Leonardo only
  }
  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());
}

What is the difference between, why use 2 types of calls to make AT command calls.

SoftwareSerial mySerial (10,11) mySerial.begin(10,11)

and

Serial.begin(9600)

Siddharth
  • 245
  • 2
  • 4
  • 12