Skip to main content
added 116 characters in body
Source Link
antony.trupe
  • 381
  • 2
  • 9
  • 24

I thought that hooking the same wire into two pins(2 and 3, on an Uno) would work, but it doesn't appear to be.

The sketch looks like such.

byte b;

NewSoftSerial nss(2,3);

void setup()
{
  nss.begin(9600);
  Serial.begin(9600);
}

void loop() {
  // if theres data from the bluetooth module
  if (nss.available()>0) {//this is never true
    //echo it to the serial monitor
    Serial.print("nss echo:");
    Serial.println((char)nss.read(),BYTE);
  }
  if (Serial.available()>0) {
    b=Serial.read();
    //echo it back to the serial monitor
    Serial.print("serial echo:");

    Serial.println(b,BYTE);
    //send it to the bluetooth module
    nss.print(b,BYTE);
  }
}

I expected to see pairs of outputs for every input.

serial echo:g
nss echo:g

What am I doing wrong?

I thought that hooking the same wire into two pins(2 and 3, on an Uno) would work, but it doesn't appear to be.

The sketch looks like such.

byte b;

NewSoftSerial nss(2,3);

void setup()
{
  nss.begin(9600);
  Serial.begin(9600);
}

void loop() {
  // if theres data from the bluetooth module
  if (nss.available()>0) {//this is never true
    //echo it to the serial monitor
    Serial.print("nss echo:");
    Serial.println((char)nss.read(),BYTE);
  }
  if (Serial.available()>0) {
    b=Serial.read();
    //echo it back to the serial monitor
    Serial.print("serial echo:");

    Serial.println(b,BYTE);
    //send it to the bluetooth module
    nss.print(b,BYTE);
  }
}

I thought that hooking the same wire into two pins(2 and 3, on an Uno) would work, but it doesn't appear to be.

The sketch looks like such.

byte b;

NewSoftSerial nss(2,3);

void setup()
{
  nss.begin(9600);
  Serial.begin(9600);
}

void loop() {
  // if theres data from the bluetooth module
  if (nss.available()>0) {//this is never true
    //echo it to the serial monitor
    Serial.print("nss echo:");
    Serial.println((char)nss.read(),BYTE);
  }
  if (Serial.available()>0) {
    b=Serial.read();
    //echo it back to the serial monitor
    Serial.print("serial echo:");

    Serial.println(b,BYTE);
    //send it to the bluetooth module
    nss.print(b,BYTE);
  }
}

I expected to see pairs of outputs for every input.

serial echo:g
nss echo:g

What am I doing wrong?

Source Link
antony.trupe
  • 381
  • 2
  • 9
  • 24

How do I test NewSoftSerial?

I thought that hooking the same wire into two pins(2 and 3, on an Uno) would work, but it doesn't appear to be.

The sketch looks like such.

byte b;

NewSoftSerial nss(2,3);

void setup()
{
  nss.begin(9600);
  Serial.begin(9600);
}

void loop() {
  // if theres data from the bluetooth module
  if (nss.available()>0) {//this is never true
    //echo it to the serial monitor
    Serial.print("nss echo:");
    Serial.println((char)nss.read(),BYTE);
  }
  if (Serial.available()>0) {
    b=Serial.read();
    //echo it back to the serial monitor
    Serial.print("serial echo:");

    Serial.println(b,BYTE);
    //send it to the bluetooth module
    nss.print(b,BYTE);
  }
}