how to set up raido control

hi i am using an mega 2560, seeed studio motor shield, and a radio controller spektrum dx5e with receiver spektrum ar600
i am trying to build a robot that a can run around the yard but i cant grasp the concept of getting the arduino motor shield
and radio receiver to work together. I have been working with arduino for about 4 months now and am new to this.

thanks for the help in advance.

Post some links of what you have.

hears what i have to work with the first script is for the seed studio motor shield. the other is a script i found on the internet that shows how to set up with the receiver spektrum ar600. thanks in advance

//. Motor driver shield- 2012 Copyright (c) Seeed Technology Inc.
//
// Original Author: Jimbo.we
// Contribution: LG
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

int pinI1=8;//define I1 interface
int pinI2=11;//define I2 interface
int speedpinA=9;//enable motor A
int pinI3=12;//define I3 interface
int pinI4=13;//define I4 interface
int speedpinB=10;//enable motor B
int spead =127;//define the spead of motor

void setup()
{
pinMode(pinI1,OUTPUT);
pinMode(pinI2,OUTPUT);
pinMode(speedpinA,OUTPUT);
pinMode(pinI3,OUTPUT);
pinMode(pinI4,OUTPUT);
pinMode(speedpinB,OUTPUT);
}

void forward()
{
analogWrite(speedpinA,spead);//input a simulation value to set the speed
analogWrite(speedpinB,spead);
digitalWrite(pinI4,HIGH);//turn DC Motor B move clockwise
digitalWrite(pinI3,LOW);
digitalWrite(pinI2,LOW);//turn DC Motor A move anticlockwise
digitalWrite(pinI1,HIGH);
}
void backward()//
{
analogWrite(speedpinA,spead);//input a simulation value to set the speed
analogWrite(speedpinB,spead);
digitalWrite(pinI4,LOW);//turn DC Motor B move anticlockwise
digitalWrite(pinI3,HIGH);
digitalWrite(pinI2,HIGH);//turn DC Motor A move clockwise
digitalWrite(pinI1,LOW);
}
void left()//
{
analogWrite(speedpinA,spead);//input a simulation value to set the speed
analogWrite(speedpinB,spead);
digitalWrite(pinI4,HIGH);//turn DC Motor B move clockwise
digitalWrite(pinI3,LOW);
digitalWrite(pinI2,HIGH);//turn DC Motor A move clockwise
digitalWrite(pinI1,LOW);
}
void right()//
{
analogWrite(speedpinA,spead);//input a simulation value to set the speed
analogWrite(speedpinB,spead);
digitalWrite(pinI4,LOW);//turn DC Motor B move anticlockwise
digitalWrite(pinI3,HIGH);
digitalWrite(pinI2,LOW);//turn DC Motor A move clockwise
digitalWrite(pinI1,HIGH);
}
void stop()//
{
digitalWrite(speedpinA,LOW);// Unenble the pin, to stop the motor. this should be done to avid damaging the motor.
digitalWrite(speedpinB,LOW);
delay(1000);

}

void loop()
{
left();
delay(2000);
stop();
right();
delay(2000);
stop();
// delay(2000);
forward();
delay(2000);
stop();
backward();
delay(2000);
stop();
}

hear is the other script.

int rx1 = 0; //throttle control
int rx2 = 0; //aileron control
int rx3 = 0; //elevation control
int rx4 = 0; //rudder control
int rx5 = 0; //AUX switch
int rx6 = 0; //Trainer momentary switch
#include <Arduino.h>
unsigned long time1 = 0;
unsigned long time2 = 0;
void setup() {
// initialize
Serial.begin(115200); // open the serial port at 115200 bps:
}
void loop() {
rx1=pulseIn(A0,HIGH);
rx2=pulseIn(A1,HIGH);
rx3=pulseIn(A2,HIGH);
rx4=pulseIn(A3,HIGH);
rx5=pulseIn(2,HIGH);
rx6=pulseIn(3,HIGH);
Serial.print(rx1);
Serial.print("\t");
Serial.print(rx2);
Serial.print("\t");
Serial.print(rx3);
Serial.print("\t");
Serial.print(rx4);
Serial.print("\t");
Serial.print(rx5);
Serial.print("\t");
Serial.print(rx6);
Serial.print("\t");
Serial.println("\t");
}

I need links to the parts you have.

You haven't said how you have the receiver connected to the Mega. Have you a common ground?

I assume you have a connection from each of the receiver outputs to a different pin of the Mega.

I presume you are using pulseIn() to measure the width of the pulses.

If so then all you need to do is make your machine respond according to the changing pulse widths. You will probably need a little experimenting to find the max and min widths on each channel.

...R

i am using pins 8,A9,A10,A11,A12,A13 for my receiver. i never did think about using pulseIn().
thanks i will give it another go and see what i can do.

Weird.

The only reason I mentioned pulseIn is because I saw it in your code !!!!

Is there any reason why you seem to have chosen the analog pins? This isn't an analog problem, however the analog pins also function as digital pins.

...R

i never put much thinking into witch pins to use. i do have pins 14,15,16,17,18,19. pins open on the other side.
if i may ask witch wood be a better choice to use?
thanks

You didn't say why you had pulseIn() in your code, but appeared not to know. This is at the core of getting your project to work.

And you don't seem to have picked up on my comment that the analog pins can be used as digital pins. Any pin that pulseIn() will work on will be OK. But you have to approach every decision you make with care and not just scatter connections around.

...R

thanks for thew help

hi i need a little help i am having a problem under standing how to get my rc receiver to communicate with my arduino i can read it wen i set it up with serial monitor. were i am having problems is writing the sketch to get my motors to go froward.
thanks for help in advance.

You will have to let us see your code together with a description of what it should be doing and what it is actually doing.

...R

what i am trying to do is make it move forward when i push the joy stick forward for starters. what i have gotten so far is forward movement but not with joystick forward. and i can get my serial monitor to work and show i am receiving signal from the rc receiver . if i have left any thing out pleas let me know and thank u in advance.

this is what i have so far.

int pinI1=8;//define I1 interface
int pinI2=11;//define I2 interface 
int speedpinA=9;//enable motor A
int pinI3=12;//define I3 interface 
int pinI4=13;//define I4 interface 
int speedpinB=10;//enable motor B
int spead =127;//define the spead of motor


void setup()
{
  pinMode(pinI1,OUTPUT);
  pinMode(pinI2,OUTPUT);
  pinMode(speedpinA,OUTPUT);
  pinMode(pinI3,OUTPUT);
  pinMode(pinI4,OUTPUT);
  pinMode(speedpinB,OUTPUT);
}

void forward()
{
     analogWrite(speedpinA,spead);//input a simulation value to set the speed
     analogWrite(speedpinB,spead);
     digitalWrite(pinI4,HIGH);//turn DC Motor B move clockwise
     digitalWrite(pinI3,LOW);
     digitalWrite(pinI2,LOW);//turn DC Motor A move anticlockwise
     digitalWrite(pinI1,HIGH);
}

foward();

this is were i got my example code. on how to use my motor shield.

//. Motor driver shield- 2012 Copyright (c) Seeed Technology Inc.
//
// Original Author: Jimbo.we
// Contribution: LG
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

int pinI1=8;//define I1 interface
int pinI2=11;//define I2 interface 
int speedpinA=9;//enable motor A
int pinI3=12;//define I3 interface 
int pinI4=13;//define I4 interface 
int speedpinB=10;//enable motor B
int spead =127;//define the spead of motor
 
void setup()
{
  pinMode(pinI1,OUTPUT);
  pinMode(pinI2,OUTPUT);
  pinMode(speedpinA,OUTPUT);
  pinMode(pinI3,OUTPUT);
  pinMode(pinI4,OUTPUT);
  pinMode(speedpinB,OUTPUT);
}
 
void forward()
{
     analogWrite(speedpinA,spead);//input a simulation value to set the speed
     analogWrite(speedpinB,spead);
     digitalWrite(pinI4,HIGH);//turn DC Motor B move clockwise
     digitalWrite(pinI3,LOW);
     digitalWrite(pinI2,LOW);//turn DC Motor A move anticlockwise
     digitalWrite(pinI1,HIGH);
}
void backward()//
{
     analogWrite(speedpinA,spead);//input a simulation value to set the speed
     analogWrite(speedpinB,spead);
     digitalWrite(pinI4,LOW);//turn DC Motor B move anticlockwise
     digitalWrite(pinI3,HIGH);
     digitalWrite(pinI2,HIGH);//turn DC Motor A move clockwise
     digitalWrite(pinI1,LOW);
}
void left()//
{
     analogWrite(speedpinA,spead);//input a simulation value to set the speed
     analogWrite(speedpinB,spead);
     digitalWrite(pinI4,HIGH);//turn DC Motor B move clockwise
     digitalWrite(pinI3,LOW);
     digitalWrite(pinI2,HIGH);//turn DC Motor A move clockwise
     digitalWrite(pinI1,LOW);
}
void right()//
{
     analogWrite(speedpinA,spead);//input a simulation value to set the speed
     analogWrite(speedpinB,spead);
     digitalWrite(pinI4,LOW);//turn DC Motor B move anticlockwise
     digitalWrite(pinI3,HIGH);
     digitalWrite(pinI2,LOW);//turn DC Motor A move clockwise
     digitalWrite(pinI1,HIGH);
}
void stop()//
{
     digitalWrite(speedpinA,LOW);// Unenble the pin, to stop the motor. this should be done to avid damaging the motor. 
     digitalWrite(speedpinB,LOW);
     delay(1000);
 
}

void loop()
{
  left();
  delay(2000);
  stop();
  right();
  delay(2000);
  stop();
 // delay(2000);
  forward();
  delay(2000);
  stop();
  backward();
  delay(2000); 
  stop(); 
}

and hear is an example i found on how to setup my rc receiver with arduino

int rx1 = 0;  //throttle control
int rx2 = 0;  //aileron control
int rx3 = 0;  //elevation control
int rx4 = 0;  //rudder control
int rx5 = 0;  //AUX switch
int rx6 = 0;  //Trainer momentary switch
#include <Arduino.h>
unsigned long time1 = 0;
unsigned long time2 = 0;
void setup() {
                   // initialize 
  Serial.begin(115200);      // open the serial port at 115200 bps:
}
void loop() {
  rx1=pulseIn(A0,HIGH);
  rx2=pulseIn(A1,HIGH);
  rx3=pulseIn(A2,HIGH);
  rx4=pulseIn(A3,HIGH);
  rx5=pulseIn(2,HIGH);
  rx6=pulseIn(3,HIGH);
  Serial.print(rx1);
  Serial.print("\t");
  Serial.print(rx2);
  Serial.print("\t");
  Serial.print(rx3);
  Serial.print("\t");
  Serial.print(rx4);
  Serial.print("\t");
  Serial.print(rx5);
  Serial.print("\t");
  Serial.print(rx6);
  Serial.print("\t");
  Serial.println("\t");
}

what i am trying to do is make it move forward when i push the joy stick forward for starters. what i have gotten so far is forward movement but not with joystick forward.

Ok, so if not with the joystick, how did you get "it" to move forward?
The example code you found, outputs data when a command is given, so what readings are you getting when you send the receiver a command? If you push the joystick forward and reverse, do you see any change in readings? Could you perhaps post what you are getting?

so what readings are you getting when you send the receiver a command? If you push the joystick forward and reverse, do you see any change in readings? Could you perhaps post what you are getting?

hears what reading i got. i dont know how much u need for info on the readings.

 thro  aile elev rudd gear
back 1093   0     0       0       0
           1098   0     0       0       0
 forward 1096   0     0       0       0

Ok, so if not with the joystick, how did you get "it" to move forward?

were the forward is i put pinMode(A5=A0,HIGH) under that and it took off moving forward.
the A5 is the pin on the mega 2560 and the A0 is a pin on the motor shield.
now the controller i have is for an rc airplane i don't think i had noted that.
if there is any thing i missed let me know and thanks for the help in advance.

well i have Ben thinking and i was wondering if trying to use the RC controller as a type of potentiometer wood be a way to go with programming my arduino to receive the signal from my receiver. plus i am all out of ideas was hoping i could bounce this idea around and see what all of u think about this idea. thanks in advance.

sprocive:
well i have Ben thinking and i was wondering if trying to use the RC controller as a type of potentiometer wood be a way to go with programming my arduino to receive the signal from my receiver. plus i am all out of ideas was hoping i could bounce this idea around and see what all of u think about this idea. thanks in advance.

If you want to know how to interface an Arduino with an RC receiver, check out the code example for the Dagu Wild Thumper motor controller board:

There is a link to the example code there.

Basically, the Dagu Wild Thumper controller is an Arduino compatible ATMega328 based motor and servo controller board, meant to be used with the Wild Thumper 6WD chassis (sold seperately). It can be programmed to operate autonomously, or in an "assist" mode (with RC input), or as straight pass-thru of the RC inputs to the motors and/or servos.

The basics of how it works is that it takes the PPM output of the RC receiver, and using the Arduino pulseIn() function:

...it decodes the timing of the PPM, then uses that to control the motors or other functions of the chassis.

The code is pretty well commented and easy to follow (last I looked, anyhow). You should be able to adapt it to your project fairly easily (note - this will not be a simple "drop-it-in-and-go" type project - you will need to read the code, understand it, and do your own implementation - think of it as a tutorial, of sorts).

Good luck - hope it helps.