Good day,
I have been looking everywhere books, etc... I am a novice with xbees.
I am trying to pass analog signal X&Y from pot and render in arduino then send value to other arduino with xbee SERIE 1 to other Arduino.
This is my second version of sketch to try to accomplish this and now I am to a lost and looking for guidance. I have somewhat success, upon powering up the remote first everything is good, once I power up the power supply one motor only turns slowly but should not, when playing with the joystick I can speed up the motor pressing joystick one way but the other direction does not make the motor go backward.
Thank you very much
Material:
2 xbees series 1
2 dc motors
1 sabertooth driver board
1 joystick
12 volts baterie
9 volts batterie
I have attached the schema for both remote and receiver and below is the sketches for both arduino. Both xbees are reset to default settings
Remote
#include <EasyTransfer.h>
EasyTransfer ET;
const int potpin1 = A0;
const int potpin2 = A1;
struct SEND_DATA_STRUCTURE{
int servo1val;
int servo2val;
};
SEND_DATA_STRUCTURE txdata;
void setup(){
Serial.begin(9600);
// Serial.begin(115200);
ET.begin(details(txdata), &Serial);
// pinMode(potpin1, INPUT);
// pinMode(potpin2, INPUT);
}
void loop(){
int val1 = analogRead(potpin1);
int val2 = analogRead(potpin2);
val1 = map(val1, 0, 1023, 0, 179);
val2 = map(val2, 0, 1023, 0, 179);
txdata.servo1val = val1;
txdata.servo2val = val2;
ET.sendData();
}
Receiver
#include <Servo.h>
#include <EasyTransfer.h>
EasyTransfer ET;
Servo myservo1;
Servo myservo2;
Servo ST1, ST2;
struct RECEIVE_DATA_STRUCTURE{
int servo1val;
int servo2val;
};
RECEIVE_DATA_STRUCTURE txdata;
void setup(){
Serial.begin(9600);
// Serial.begin(115200);
ET.begin(details(txdata), &Serial);
// Servo
ST1.attach( 6, 1000, 2000);
ST2.attach(5, 1000, 2000);
}
void loop(){
if(ET.receiveData()){
ST1.write(txdata.servo1val);
ST2.write(txdata.servo2val);
//ST1.write(map(txdata.servo1val, 0, 1023, 0, 180));
//ST2.write(map(txdata.servo2val, 0, 1023, 0, 180));
}
}
FirstBotController.fzz (8.01 KB)
FirstBotReceiver.fzz (9.75 KB)