Hi. I have been trying all night to get SoftSerial to work, but without success.
I have tried the example included with Arduino 1.0.3:
#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());
}
I have connected a wire directly between pin 10 and 11. Nothing else.
When I open serial monitor, "Goodnight moon!" is printed as expected.
However, when I write something in the serial terminal, I can see that the Rx LED on Arduino is flashing, but nothing is displayed in the terminal.
Maybe I should add that I am using an Arduino Uno.
Before I connected a wire between pin 10 and 11, I had connected an IR diode to pin 10 and an IR receiver to pin 11. The diode was connected through a 470 ohm resistor and the receiver was connected as a voltage divider through a 10 kohm resistor. I have exactly the same configuration on another Arduino, so I know that it should work.
When I used this hardware, and held the tranmitter and the diode close to each other, I could see that the character ÿ was received, no matter what I entered in the serial monitor.
To make sure my hardware was not causing the problem, I disconnected everything and replaced it with a wire between pin 10, and 11, but now I can't receive anything at all.
PaulS:
Isn't that a call to mySerial.begin() two lines after the Serial.print() of 'Goodnight, moon"?
Um ... um ... so it is. I'd have sworn that wasn't there last time I looked.
Suggest putting in a direct echo of everything received from Serial back over Serial, just to confirm your input is getting as far as your sketch. Also put markers around all text when you print it to Serial so that you can tell whether you're receiving unprintable characters.