Does this code mean we are creating two objects? How are these objects being initialized and used?How come we used Serial.begin() straight away?
Could you please help me understand the concept?
#include<SoftwareSerial.h>
SoftwareSerial mySerial(10,9); // are we creating an object to SoftwareSerial class?
void setup(){
mySerial.begin(115200);
Serial.begin(9600);
//more statements
}
SoftwareSerial will not work at 115200 baud rate and 38400 can be problematic. I would use 9600 as the baud rate for SS.
li16:
so where does Serial.print(variable) appear and where does the mySerial.print(variable) appear
Serial.print() sends text to whatever's connected to the Arduino's hardware serial interface. Normally this means the serial monitor on your computer (via the USB interface) but there are other ways to set this up (eg you could connect something to pins 0 and 1).
mySerial.print() sends text to the the software serial object, so the data is sent out of whatever pins you defined when you set up the software serial object.
GypsumFantastic:
Serial.print() sends text to whatever's connected to the Arduino's hardware serial interface. Normally this means the serial monitor on your computer (via the USB interface) but there are other ways to set this up (eg you could connect something to pins 0 and 1).
mySerial.print() sends text to the the software serial object, so the data is sent out of whatever pins you defined when you set up the software serial object.
If I'm not mistaken, I think OP's ask was where is the code for the print() method - and how does this work. if that's the case answer #7 should help