Good day,
I am trying to control motors wireless, I am able to transmit the signal and run it through a sketch on the arduino receiving but for some reason when applying the joystick in one direction I cant get full power from the motors. I cant troubleshoot with Arduino Uno via terminal.
So far I have only configure 1 output pin to test the signal going to the xbee/arduino receiving.
Help would be appreciated if you can figure out why one direction is not working properly and the other direction respond correctly
Problem:
xbee series 1 settings
Transmitter xbee settings
ATRE
ATMY1234
ATDL5678
ATDH0
ATID0
ATD02
ATIR64
ATWR
Receiver xbee settings:
ATRE
ATMY5678
ATDL1234
ATDH0
ATID0
ATWR
sketch in Arduino receiving
/*
XBeeAnalogReceiveSeries1
Read an analog value from an XBee API frame and set value accordingly.
*/
#include <Servo.h>
int servoVal;
int servoVal2;
Servo ST1, ST2;
void setup() {
// Servo
ST1.attach( 6, 1000, 2000);
ST2.attach(5, 1000, 2000);
Serial.begin(9600);
configureRadio(); // check the return value if you need error handling
}
boolean configureRadio() {
// put the radio in command mode:
Serial.flush();
Serial.print("+++");
delay(100);
String ok_response = "OK\r"; // the response we expect.
// Read the text of the response into the response variable
String response = String("");
while (response.length() < ok_response.length()) {
if (Serial.available() > 0) {
response += (char) Serial.read();
}
}
// If we got the right response, configure the radio and return true.
if (response.equals(ok_response)) {
Serial.print("ATAP1\r"); // Enter API mode
delay(100);
Serial.print("ATCN\r"); // back to data mode
return true;
} else {
return false; // This indicates the response was incorrect.
}
}
void loop() {
if (Serial.available() >= 14) { // Wait until we have a mouthful of data
if (Serial.read() == 0x7E) { // Start delimiter of a frame
// Skip over the bytes in the API frame we don't care about
for (int i = 0; i < 10; i++) {
Serial.read();
}
// The next two bytes are the high and low bytes of the sensor reading
int analogHigh = Serial.read();
int analogLow = Serial.read();
int analogValue = analogLow + (analogHigh * 180);
servoVal = map(analogValue, 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
}
}
}