Remote Controlled Lawn Mower

Hi guys,

i am seeking for some information and help, i like to make a remote controlled lawnmower what is using a 6ch transmitter and receiver
two wheelchair motor 8A 24V each 100W
2 12V 70AH battery
a 6A dual motor driver /h bridge/
i have two relays

if i Hooke them up all works motor turning the arduino reacts to the receiver but something with the pwm is not right as the wheels just sniping all the time so i guessing the code i am using is not correct

is there anyone here could give me some help hove to solve the problem or if you can explain how to write a code what would work

i have the code here

i will appreciate any help or if you can guide me to someone who already made this project

/*
RC LAWN MOWER
By: Gabor Nemeth
Feel free to use or change any of the details, I have made this code for my Electric remote control lawn mower.
Let me know if you make hugely, awesome, great changes.
*/

int ch1; // Here's where we'll keep our channel values
int ch2;
int ch3;
int ch4;
int switchA; // This is the Light ON OFF switch
int switchD; // This is the Engine kill switch

int move; // Forward/Back speed
int turn; // Turning Factor
int swd;
int swa;

int pwm_a = 3; //PWM control for motor outputs
int pwm_b = 11; //PWM control for motor outputs
int dir_a = 12; //direction control for motor outputs
int dir_b = 13; //direction control for motor outputs
int relay1 = 9; //relay for engine kill switch outputs
int relay2 = 8; //relay for Light switch outputs

void setup() {

pinMode(5, INPUT); // Set our input pins as such
pinMode(6, INPUT);
pinMode(7, INPUT);
pinMode(A0, INPUT);
pinMode(A1, INPUT);

Serial.begin(9600); // Pour a bowl of Serial (for debugging)

pinMode(pwm_a, OUTPUT); //Set control pins to be outputs
pinMode(pwm_b, OUTPUT);
pinMode(dir_a, OUTPUT);
pinMode(dir_b, OUTPUT);
pinMode(relay1, OUTPUT);
pinMode(relay2, OUTPUT);

analogWrite(pwm_a, 0);
analogWrite(pwm_b, 0);
}

void loop() {

ch1 = pulseIn(5, HIGH, 25000); // Read the pulse width of
ch2 = pulseIn(6, HIGH, 25000); // each channel
ch3 = pulseIn(7, HIGH, 25000);
swd = pulseIn(A0, HIGH,25000);
swa = pulseIn(A1, HIGH,25000);
/*
if(ch1>1000){Serial.println("Left Switch: Engaged");}
if(ch1<1000){Serial.println("Left Switch: Disengaged");}

Serial.print("Right Stick X:");
Serial.println(map(ch3, 1000,2000,-500,500));

Serial.print("Right Stick Y:");
Serial.println(map(ch2, 1000,2000,-500,500));

Serial.print(SWD:");
Serial.printIn(map(switchD, 1000,2000,-500,500));

Serial.print(SWA:");
Serial.printIn(map(switchD, 1000,2000,-500,500));

Serial.println();

delay(100);

clearAndHome();
*/

move = map(ch2, 1000,2000, -500, 500); //center over zero
move = constrain(move, -255, 255); //only pass values whose absolutes are
//valid pwm values

/What we're doing here is determining whether we want to move
forward or backward
/
if(move>0){digitalWrite(dir_a, 1);digitalWrite(dir_b, 1);};
if(move<0){digitalWrite(dir_a, 0);digitalWrite(dir_b, 0); move=abs(move);};

/Here we're determining whether a left or a right turn is being
executed
/
turn = map(ch1, 1000,2000,-500,500);
turn = constrain(turn, -255, 255);

/This is where we do some mixing, by subtracting our "turn"
variable from the appropriate motor's speed we can execute
a turn in either direction
/
if(turn>0){analogWrite(pwm_b, move-turn); analogWrite(pwm_a, move);};
if(turn<0){turn=abs(turn); analogWrite(pwm_a, move-turn); analogWrite(pwm_b, move);};

/Here we're determining whether we kill the engine or let it run/
swd = map(swd,0,15,0,255);
swd = constrain(swd, -255, 255); //only pass values whose absolutes are
//valid pwm values

if(swd>0){digitalWrite(relay1, 0);};
if(swd<0){digitalWrite(relay1, 1); swd=abs(swd);};

/Here we're determining whether we have the lights on or not/
swa = map(swa,0,15,0,255);
swa = constrain(swa, -255, 255); //only pass values whose absolutes are
//valid pwm values

if(swa>0){digitalWrite(relay2, 0);};
if(swa<0){digitalWrite(relay2, 1); swa=abs(swa);};

Serial.print("move:"); //Serial debugging stuff
Serial.println(move);

Serial.print("turn:"); //Serial debugging stuff
Serial.println(turn);

Serial.print("move-turn:"); //Serial debugging stuff
Serial.println(move-turn);

Serial.print("switch:"); //Serial debugging stuff
Serial.print(swd);

Serial.print("switch:"); //Serial debugging stuff
Serial.print(swa);

Serial.println(); //Serial debugging stuff
Serial.println();
Serial.println();

}

Please help as the lawn growing fast :wink:

Don't cross-post !!!!

His other post about same topic: http://forum.arduino.cc/index.php?topic=544633.msg3711959#msg3711959

.

ye i am sorry about this i try to delete that post but cant for some reason

apologize for it