Hi Everyone
I am having a little trouble implementing communication between two Arduinos (mega 2560) using Xbee Series 1s and the wireless proto shield from Arduino. They are all in transparent mode, and have the latest firmware.
One is sending a number, read from a potentiometer using this code:
#include <Potentiometer.h>
Potentiometer potentiometer = Potentiometer(2); //a Potentiometer at analog in 2
void setup(){
Serial.begin(9600);
}
void loop(){
Serial.println(potentiometer.getValue(),DEC);
delay (500)
}
This is working fine, as I get the right results using an xbee explorer and the arduino serial monitor. However, when I try to receive this on the other arduino, using the following code
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);
}
if (Serial.available() == 0) {
// say what you got:
Serial.println("I received nothing");
}
delay (250);
}
and using the arduino serial monitor to check the result, I get an output like the following
I received: 50
I received: 51
I received: 50
I received: 51
I received: 50
I received: 51
I received: 50
I received: 51
I received: 50
I received: 51
I received: 50
I received: 51
I received: 50
I received: 51
I received: 50
I received: 51
I received: 50
I received: 51
I received: 50
I received: 51
I received: 50
for reference it should be more like
237
237
237
237
237
237
237
237
237
237
237
237
237
237
237
(from explorer)
where am I going wrong? I have swapped around the xbees and have the same problem which ever one recieving
Many thanks as always
Alex