Good day,
I have started a project a while back and decided to add extra to it by making it wireless, basically a remote control bot.
I have been reading and playing around trying to configure the xbees and failed. I would like if possible to transfer analog signal from transmitter to receiver. I have been looking at the API mode which seem to be easy but I might be wrong.
I have 2 xbees series 1
2 Arduino Uno
1 Joystick
2 explorer adaptor
The remote control is a simple plastic box holding an Arduino Uno, a switch, breadboard, batterie and joystick. The Arduino transmiter capture the Analog signal X&Y from joystick send to xbee conected to Arduino and the signal is then captured by the xbee receiver sending the 2 analog signal to the sketch in Arduino ouptut it from PWM pins from Arduino to motors. The Arduino in the remote control is because I will be adding other features to the remote control in the future. The Arduino in the remote control help regulate voltage at the same time, fed with a 9 volts batterie.
The receiver would have the same setup inside a plastic box an Arduino Uno, xbee serie 1, switch. The receiver would read the analog signal from the xbee and send to pin A0&A1 then the sketch in Arduino would have the output out from PWM pins to motors.
I have built a very simple sketch capturing the signal, Should both Arduino be running the same sketch? Is it feasable to pass analog signal to xbee receiver and having xbee receiver capturing and outputing the analog signal to another Arduino?
For setting up the xbee maybe there is a simplier method? Or exactly how to configure them? Any advice would be greatly appreciated.
/*
Hardware:
- Arduino Uno
- Sabertooth 25 Dual 25A Motor Driver;kl
- 1 Mini Thumb Joystick
- 2 dc motors (using servo library since Sabertooth seem to only accept for R/C or micro controller control
- the joystick#1 up/down control forward backaward/ left/right
Features:
- Move 2 motors using one Joystick Independently
The circuit:
- First motor signal out PWM pin 10 to sabertooth S2
- Second motor signal out PWM pin 3 to sabertooth S1
- Joystick1 X angle attached to analog pins A0
- Joystick1 Y angle attached to analog pins A1
Discontinued - Joystick2 X angle attached to analog pins A2
Discontinued - Joystick2 Y angle attached to analog pins A3
Author:
Fabiolus
sabertooth switch
1= down
2= up
3= up
4= up if this switch is up it changes the S2 motor and S1 making it easy to steer one goes
\ forward the other goes backward, you can apply to joystick#2 and #1 for backward/forward
5= down
6= down
*/
#include <Servo.h>
const int joyX1 = A0; // Joystick 1 X Axis
const int joyY1 = A1; // Joystick 1 Y Axis
//const int joyX2 = A2; // Joystick 2 X Axis
//const int joyY2 = A3; // Joystick 2 y Axis
int servoVal;
int servoVal2;
Servo ST1, ST2;
void setup() {
// Servo
ST1.attach( 6, 1000, 2000);
ST2.attach(5, 1000, 2000);
// Inizialize Serial
Serial.begin(9600);
}
void loop(){
// Display Joystick values using the serial monitor
outputJoystick();
// Read the X joystick value (value between 0 and 1023)
servoVal = analogRead(joyX1);
servoVal = map(servoVal, 0, 1023, 0, 180); // scale it to use it with the servo (result between 0 and 180)
ST1.write(servoVal); // sets the servo position according to the scaled value
// Read the Y joystick value (value between 0 and 1023)
servoVal2 = analogRead(joyY1);
servoVal2 = map(servoVal2, 0, 1023, 0, 180); // scale it to use it with the servo (result between 70 and 180)
ST2.write(servoVal2); // sets the servo position according to the scaled value
delay(15); // waits for the servo to get there
}
/**
* Display joystick values for testing
*/
//void outputJoystick(){
//Serial.print(analogRead(joyX1));
// Serial.print ("---");
//Serial.print(analogRead(joyX2));
// Serial.println ("----------------");
// Serial.print(servoVal2);
//}
void GoForward (){
}
FirstBotController.fzz (10.4 KB)
FirstBotReceiver.fzz (12.2 KB)