Go Down

Topic: Xbee + SerLCD: problem with LCD.print... (Read 1 time) previous topic - next topic

somedude__

Mar 30, 2011, 04:36 am Last Edit: Mar 30, 2011, 04:38 am by somedude__ Reason: 1
Hi all,

This is my first post...I thank you in advance for reading & helping!

I am trying to get two arduino with Xbee attached talking to each other. The transmitter unit will send some characters, and then depending on what character is broadcasted the receiver unit (with SerLCD attached) will print some selection of texts. Here are my codes:

Transmitter:

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

void loop()
{
 Serial.print('X');
 delay(1000);
 Serial.print('O');
 delay(1000);
}

Receiver:

#include <SoftwareSerial.h>
#define txPin 9
SoftwareSerial LCD = SoftwareSerial(0, txPin);

void setup()
{
 Serial.begin(9600);
 pinMode(txPin, OUTPUT);
 pinMode(13, OUTPUT);
 LCD.print(0x7C, BYTE);   //command flag for backlight stuff
 LCD.print(128, BYTE);    //light level
}

void loop()
{
 while (Serial.available() > 0)
 {
   char c = Serial.read();
   if (c == 'X')
   {
     LCD.print("This Thing"); //print
     delay(500);
   }
   if (c == 'O')
   {
     LCD.print("THis Other Thing");   //print
     delay(500);
   }
 }
}

My Xbees are sitting on top of xbee shields. I tested the Xbee units and I am able to send Xs and Os between them without problem. But the LCD just wouldn't print anything. I tried modifying the codes to get the LCD to just print whatever is seen by Serial.read, and that didn't work either...What did I do wrong?

Thanks!! - David


jgordo32

Have you tried looking at the serial monitor on both ends? That should provide some useful debugging information.

Also, it seems obvious so you probably already did this, but have you been able to print anything to your LCD regardless of the wireless information?

somedude__

#2
Mar 31, 2011, 06:00 am Last Edit: Mar 31, 2011, 06:06 am by somedude__ Reason: 1
Yes I tested the LCD and I am able to print stuff on it - when I am not asking Arduino to also listen to the serial port...Basically, sending and receiving Xs and Os serially is fine on its own, printing to LCD is fine on its own, but try putting the two together then nothing happens...  =(

It might have something to do with the management of multiple instances of serial communication in NewSoftSerial? I found this link but I don't think I fully understand the solution....http://arduiniana.org/libraries/newsoftserial/

- D

Go Up