I am having trouble in using software serial library. I have compiled and run the program below.
When I run, I see the serial monitor. It only shows "Goodnight moon!".
Why "Hello, world?" not shown?
and when I input any character from the serial monitor, not read by the myserial.
here is my code :
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11); // RX, TX
void setup()
{
Serial.begin(9600);
Serial.println("Goodnight moon!");
mySerial.begin(9600);
mySerial.println("Hello, world?");
}
void loop() // run over and over
{
if (mySerial.available())
Serial.write(mySerial.read());
if (Serial.available())
mySerial.write(Serial.read());
}
Because serial activity on pin 10 and 11 is not connected in any way with the serial monitor. You would have to connect a serial device to the software serial pins to see the "hello world".
The others seem to assume you want it to be displayed on the device connected. To me it sounds like you want to just show it on your computer (ie, for debugging).
You can do that with any serial terminal application and a USB TTL serial adapter.
or one of these, most which can also be used to program an Arduino Pro Mini or similar (the ones above can too, but you need to solder a wire onto a lead from the IC - the requirement for programming pro mini/etc is that the DTR pin is available):