Hello All
I tried going through the Arduino forums but never got any help. I’m really hoping for a different response here. Here is a quick background of my project:
I have 2 Fio V3 (from Sparkfun) and 2 XBee Pro S1. We’ll call Fio #1 the transmitter and Fio #2 the receiver. The transmitter has 2 buttons connected and the receiver has 2 servos connected. When you press button ‘A’ on the transmitter, Servo ‘A’ on the receiver will move to a specified position. When you press button ‘A’ again, the servo will move back. This will happen with button ‘B’ and servo ‘B’ as well.
When I use a Fio/XBee for the transmitter and an UNO/XBee/XBee Shield for receiver - everything works perfectly.
When I take that XBee and put it into a Fio (and change the RX, TX pin identifiers in the code)…nothing happens. I’ve even tried to simplify the code so that the receiver will send something basic to the Serial Monitor when it receives the signal(s) from the transmitter. I still get nothing. I have yet to get any indication that the XBees are talking at all when using both Fio. Then only indication is that the RSSI light illuminates on the receiver when a button is pressed. The light stays on for a moment, then turns off.
I have the XCTU software, I have configured the radios to talk and I have successfully communicated using XBee Explorer, XCTU, Serial Monitor.
Please help me…I’m so close to finishing this project.
Here is the transmitter code:
#include <SoftwareSerial.h>
SoftwareSerial XBee(0, 1); // RX, TX
int leftPin = 5;
int rightPin = 6;
int buttonL = 0;
int buttonR = 0;
void setup() {
XBee.begin(9600);
Serial.begin(9600);
pinMode(leftPin, INPUT);
pinMode(rightPin, INPUT);
}
void loop() {
buttonL = digitalRead(leftPin);
buttonR = digitalRead (rightPin);
if (buttonL == HIGH)
{
Serial.print ("A");
XBee.print ("A");
delay (500);
}
if (buttonR == HIGH)
{
Serial.print ("B");
XBee.print ("B");
delay (500);
}
}
Here is the Receiver Code:
#include <Servo.h>
#include <SoftwareSerial.h>
SoftwareSerial XBee2(0, 1); // Arduino RX, TX (XBee Dout, Din)
Servo servoLeft;
Servo servoRight;
int servStateLeft;
int servStateRight;
void setup()
{
XBee2.begin(9600);
Serial.begin (9600);
servoLeft.attach(5);
servoRight.attach(6);
servoLeft.write(30);
servoRight.write(30);
XBee2.listen();
}
void loop()
{
while (XBee2.available() < 1);
{
Serial.println ("Xbee2 is available");
char x = XBee2.read();
Serial.println(x);
switch (x){
case 'A':
servStateLeft = servoLeft.read();
switch (servStateLeft){
case 30:
servoLeft.write(150);
Serial.println("Left Servo Opened");
delay(500);
break;
case 150:
servoLeft.write(30);
Serial.println("Left Servo Closed");
delay (500);
break;
}
break;
case 'B':
servStateRight = servoRight.read();
switch (servStateRight){
case 30:
servoRight.write (150);
Serial.println ("Right Servo Opened");
delay (500);
break;
case 150:
servoRight.write (30);
Serial.println ("Right Servo Closed");
delay (500);
break;
}
}
}
}
Thank you in advance