user27036: I am using an Arduino Uno board with IDE 1.6.7.
I have tried to implement a tweaked version of the basic example (SoftwareSerial example) from the Software Serial library. The code is attached.
It should blink the light and print the message on the serial monitor. But I am not getting anything.
In fact, I also tried the example as it is. It did not work either.
#include <SoftwareSerial.h>

SoftwareSerial mySerial(8, 9); // RX, TX

void setup() {
    pinMode(13,OUTPUT);
    // Open serial communications and wait for port to open:
    Serial.begin(9600);
    while (!Serial) {
        ; // wait for serial port to connect. Needed for native USB port only
    }
    Serial.println("Goodnight moon!");
    // set the data rate for the SoftwareSerial port
    mySerial.begin(9600);
    delay(1000);
}

void loop() { // run over and over
    mySerial.println("hell");
    if (mySerial.available() > 0) {
        digitalWrite(13,HIGH);
        Serial.write("working..");
        delay(3000);
        digitalWrite(13,LOW);
        delay(2000);
    }
}


user49757: I built two scetch for testing. One for Arduino Nano no1 and another for Arduino Nano no2. They are tested and working, not only written to this page.
No2 is sending "hello" and No1 is listening and sending it to PC via Serial.
The speed (1200bps) is slow, but so it is easier to see what is happening.
Connect Pin10 of no1 to Pin11 of no2 and gnd to gnd.
Connect the Nanos to the USB-ports of the PC and set a monitor program (1200, 8N1) to listen no1.
This seems to be a good way to test Serial.print, Serial.println and Serial.write commands. You will be surprised.
/*No1:/
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11); // RX, TX
void setup() {
  Serial.begin(1200);
  Serial.println("Testing");
  mySerial.begin(1200);
}
void loop() { // run over and over
 if (mySerial.available()) //If this is missing, you get fast repeating carpage
{
    Serial.write(mySerial.read());
    Serial.print(".");
 }
}

/*No2:/
#include <SoftwareSerial.h>
 SoftwareSerial mySerial(10, 11); // RX, TX
 void setup(){
  mySerial.begin(1200);
}
void loop(){
    mySerial.print("Hello");
}


user14737: SoftwareSerial cannot transmit and receive at the same time.  So even if you connected pin 8 to 9 with a wire, your sketch will not receive what was transmitted.  That's a guess without your wiring diagram.
NeoSWSerial can simultaneously transmit and receive.  It is a drop-in replacement for SoftwareSerial.
However, AltSoftSerial is even better, and it only works on pins 8 & 9.  Use that instead!
This answer compares all 4 serial types, including HardwareSerial.

27036: <p>I am using an Arduino Uno board with IDE 1.6.7.</p>

<p>I have tried to implement a tweaked version of the basic example (<code>SoftwareSerial</code> example) from the Software Serial library. The code is attached.</p>

<p>It should blink the light and print the message on the serial monitor. But I am not getting anything.</p>

<p>In fact, I also tried the example as it is. It did not work either.</p>

<pre><code>#include &lt;SoftwareSerial.h&gt;

SoftwareSerial mySerial(8, 9); // RX, TX

void setup() {
    pinMode(13,OUTPUT);
    // Open serial communications and wait for port to open:
    Serial.begin(9600);
    while (!Serial) {
        ; // wait for serial port to connect. Needed for native USB port only
    }
    Serial.println("Goodnight moon!");
    // set the data rate for the SoftwareSerial port
    mySerial.begin(9600);
    delay(1000);
}

void loop() { // run over and over
    mySerial.println("hell");
    if (mySerial.available() &gt; 0) {
        digitalWrite(13,HIGH);
        Serial.write("working..");
        delay(3000);
        digitalWrite(13,LOW);
        delay(2000);
    }
}
</code></pre>
 49757: <p>I built two scetch for testing. One for Arduino Nano no1 and another for Arduino Nano no2. They are tested and working, not only written to this page.</p>
<p>No2 is sending &quot;hello&quot; and No1 is listening and sending it to PC via Serial.
The speed (1200bps) is slow, but so it is easier to see what is happening.</p>
<p>Connect Pin10 of no1 to Pin11 of no2 and gnd to gnd.
Connect the Nanos to the USB-ports of the PC and set a monitor program (1200, 8N1) to listen no1.</p>
<p>This seems to be a good way to test Serial.print, Serial.println and Serial.write commands. You will be surprised.</p>
<p>/*<em><strong><strong>No1:</strong></strong></em>/</p>
<pre><code>#include &lt;SoftwareSerial.h&gt;
SoftwareSerial mySerial(10, 11); // RX, TX
void setup() {
  Serial.begin(1200);
  Serial.println(&quot;Testing&quot;);
  mySerial.begin(1200);
}
void loop() { // run over and over
 if (mySerial.available()) //If this is missing, you get fast repeating carpage
{
    Serial.write(mySerial.read());
    Serial.print(&quot;.&quot;);
 }
}
</code></pre>
<p>/*<em><strong><strong>No2:</strong></strong></em>/</p>
<pre><code>#include &lt;SoftwareSerial.h&gt;
 SoftwareSerial mySerial(10, 11); // RX, TX
 void setup(){
  mySerial.begin(1200);
}
void loop(){
    mySerial.print(&quot;Hello&quot;);
}
</code></pre>
 14737: <p><code>SoftwareSerial</code> cannot transmit and receive at the same time.  So even if you connected pin 8 to 9 with a wire, your sketch will not receive what was transmitted.  That's a guess without your wiring diagram.</p>

<p><a href="https://github.com/SlashDevin/NeoSWSerial" rel="nofollow noreferrer">NeoSWSerial</a> can simultaneously transmit and receive.  It is a drop-in replacement for <code>SoftwareSerial</code>.</p>

<p>However, <a href="http://www.pjrc.com/teensy/td_libs_AltSoftSerial.html" rel="nofollow noreferrer">AltSoftSerial</a> is even better, and it only works on pins 8 &amp; 9.  Use that instead!</p>

<p><a href="https://arduino.stackexchange.com/questions/26240#26277">This answer</a> compares all 4 serial types, including <code>HardwareSerial</code>.</p>
