Hi,
I am using following setup and trying to communicate two Xbee modules:
- Arduino Duemilanove
- Sparkfun Xbee shield (not Arduino one)
- Two XBee Pro 50mW Series 2.5
- One Xbee Explorer USB
I am having some problems with serial.read and serial.available
I made the setup through the guide given on http://blog.kevinhoyt.org/wp-content/xbee-setup.pdf
and uploaded the code
#define ledPin 13
byte pinState = 0;
void setup() {
pinMode(ledPin, OUTPUT);
Serial.begin(9600);
}
void loop() {
Serial.println("testing...");
// toggle an LED just so you see the thing's alive.
toggle(13);
delay(1000);
}
void toggle(int pinNum) {
// set the LED pin using the pinState variable:
digitalWrite(pinNum, pinState);
// if pinState = 0, set it to 1, and vice versa:
pinState = !pinState;
}
I managed to see "testing..." on X-CTU terminal.
However I tried to use this following code given on the tutorial of serial.read.
int incomingByte = 0; // for incoming serial data
void setup() {
Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
}
void loop() {
// send data only when you receive data:
if (Serial.available() > 0) {
// read the incoming byte:
incomingByte = Serial.read();
// say what you got:
Serial.print("I received: ");
Serial.println(incomingByte, DEC);
}
}
But I dont get any response from X-CTU terminal. I did write number even words but no response. I am an Arduino newbie so I will be glad if you help me on what to do.
In general I was able to get data from my Arduino board through Xbee but I couldnt make Arduino work according to my commands put in X-CTU terminal.