However, i can't get these workings with my Arduino UNO. I just plugged the shields onto my arduino boards with the antennas and uploaded the following codes :
For the transmitter :
[
void setup()
{
Serial.begin(9600);
}
void loop()
{
Serial.print('H');
delay(1000);
Serial.print('L');
delay(1000);
}
]
And for the receiver :
[ const int ledPin = 13; // the pin that the LED is attached to
int incomingByte; // a variable to read incoming serial data into
void setup() {
// initialize serial communication:
Serial.begin(9600);
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
}
void loop() {
// see if there's incoming serial data:
if (Serial.available() > 0) {
// read the oldest byte in the serial buffer:
incomingByte = Serial.read();
// if it's a capital H (ASCII 72), turn on the LED:
if (incomingByte == 'H') {
digitalWrite(ledPin, HIGH);
}
// if it's an L (ASCII 76) turn off the LED:
if (incomingByte == 'L') {
digitalWrite(ledPin, LOW);
}
}
}
]
I haven't found anything in the Wiki so i really don't know what to do !
Thanks for reading my message.
It looks like you are not initializing software serial.
According to this site:
you need to do step 3
Use a jumper cap to connect XB_TX and Digital 4. Also, Use a jumper cap to connect XB_RX and Digital 5. Of course you can change the digital port as you like. But don't forget to change the port number in the definition of the demo code at the same time.
search for how to initialize software serial on forum or look at the demo code.
your Serial in your sketch would need to be changed to whatever you initialize such as
XbeeSerial(8,4) //(RX/TX)
And change my Serial.print by Serial.write in my transmitter code ?
Both transmit code and receive code need to change all of the functions using the Serial identification to XBee;. I have used print and write with xbee. I dont know if one is better than the other. so it would be XBee.print() or XBee.read() or if XBee.available().
I think it is odd that your shield does not support digital ports 0 and 1. You wouldnt have to change your code if it did. you would just put jumpers connecting the rx and tx to the digital pins on the shield. In addition the shield is blocking the RX and TX pins? I have never used a shield, but I think one of the purposes of a shield is to bring all the pins up to the second pcb.
Edit 9:32AM PT
Nevermind i see pins 0 and 1 on the shield there just not available to the xbee.
Your xbee pro modules require 215mA for transmit. Your shield doesn't give documentation on how it acquires the current. The shield says it can take any xbee module so I'm assuming it is wired to provide adequate current.
Your xbees need a U.FL antenna, However its my opinion that they will work very close range without one.
Check to see if the shields power led is light and when you run the transmit sketch on the uno check to see that the indicator light on the shield is green when the xbee is to be transmitting.
There is not much more information I can give Ill check this thread once more tomorrow or the following day.
I can't compile the transmitter sketch, i have the error 'Xbee was not declared in this scope' on the line where I wrote Xbee.write('L'), nothing happened for the line 'Xbee.write('H'), seems odd...
For the receiver i wrote this code :
const int ledPin = 13; // the pin that the LED is attached to
int incomingByte; // a variable to read incoming serial data into
void setup() {
// initialize serial communication:
Serial.begin(9600);
pinMode(ledPin, OUTPUT);
}
void loop() {
if (Serial.available() > 0) {
incomingByte = Serial.read();
if (incomingByte == 'H') {
digitalWrite(ledPin, HIGH);
}
if (incomingByte == 'L') {
digitalWrite(ledPin, LOW);
}
}
}