Pages: [1]   Go Down
Author Topic: NewSoftSerial doesn't work  (Read 745 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 46
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi everybody!!!! I try to communicate the arduino with a PC trough RS-232 using a MAX232 circuit. Te 232 circuit works good, but I try to use other lines different from (0, 1) // (rx, tx) and it doesn't work (nothing is received). Of course, (0, 1) lines work good!!!
The program is very simple, I want to use more than one serial line, so I must use other lines different from (0, 1).

Has someone any idea???

Thanks and greetings!!!

#include <NewSoftSerial.h>

    NewSoftSerial mySerial(0, 1); // (rxpin, txpin)
// (empty) also works, but (1, 0), (2, 3), (2, 4)... doesn't!!!

    void setup()
    {
    Serial.begin(9600);
    pinMode(13, OUTPUT);      // sets the digital pin as output
    }

    void loop()
    {
    Serial.println("Hello, world");
    digitalWrite(13,HIGH);
    delay(1000);
    }
« Last Edit: August 11, 2009, 05:39:03 am by Pegasux » Logged

0
Offline Offline
Faraday Member
**
Karma: 7
Posts: 2526
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You are not calling NSS anywhere.  Serial.println() is a call to hardware serial.

You want to use mySerial.println(), etc.

-j
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 46
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for your help, I changed the code, but still doesn't work!!!


#include <NewSoftSerial.h>

    NewSoftSerial mySerial(2, 3); // (rxpin, txpin)

    void setup()
    {
    mySerial.begin(9600);
    pinMode(13, OUTPUT);      // sets the digital pin as output
    }

    void loop()
    {
    mySerial.println("Hello, world");

    digitalWrite(13,HIGH);
    delay(1000);
    digitalWrite(13,LOW);
    delay(1000);
    }
Logged

Austin, TX USA
Offline Offline
God Member
*****
Karma: 4
Posts: 997
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

That code looks fine now.  My guess is that you are hooking RX to RX and TX to TX.  It should be TX  to RX and RX to TX.  Whatever you initially connected to pin 0, now connect it to pin 2.

Mikal
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 46
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks very much for your answer, you gave me an idea.... Your guess was wrong, I tried changing the lines, but It's the same, but I changed lines in a different way and it seems to work. Now I'm using "    NewSoftSerial mySerial(2, 3); // (rxpin, txpin)" but lines connected are (0, 3) and it works!!!!! both lines must be connected, if not it doesn't work. I tried now programming "NewSoftSerial mySerial(4, 3); // (rxpin, txpin)" but lines are still (0, 3) and it still works!!!! so the defined RX line is not working, always is the hardware RX line (pin 0). I tried "NewSoftSerial mySerial(4, 5); // (rxpin, txpin)" and it works on lines (0, 5), so the TX line is working good. Now I only need that the Rx line works good, but with this facts I think is a library problem and I don't know how to fix it!!!

Thanks very much for your help!!!
« Last Edit: August 12, 2009, 03:48:09 am by Pegasux » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 46
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I also tried doing "NewSoftSerial mySerial =  NewSoftSerial(4, 5);" but still the same...

Greetings!!!
Logged

0
Offline Offline
Faraday Member
**
Karma: 7
Posts: 2526
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I think is a library problem and I don't know how to fix it!!!
Sorry, but this sounds like a hardware issue to me. NSS works just fine for lots of people.

Maybe you should describe your hardware, preferably with an accurate schematic.

-j
Logged

0
Offline Offline
Sr. Member
****
Karma: 0
Posts: 375
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Did you remember to connect the ground from the device to the arduino?
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 46
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi. The 232 scheme is simple, I used it several times with XBee and Linksys WRT54G and works ok. Maybe is not the library but is the arduino board, I have another one, I will try with it.

The ground is connected to the arduino, the 232 circuit and to the RS-232 DB9.

Greetings!!
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 46
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I tried with the other arduino board that I have and it works perfectly!!! I don't know what happens to the first board... but thanks to everybody that helped me!!!!

Greetings!!
Logged

Pages: [1]   Go Up
Jump to: