Dagu Rover 5 chassis robot demo

moemzn:
Hey nick, i bought the same motor drive shield but im running a 4WD robot, im receiving a command throught a TCP server to move the robot in any direction, i wrote this code and want your opinion (Mind my low programing skills), this code is a test code.

#define motorpin0 2 // Direction ch1 front right motor

#define motorpin1 3 // Direction ch2 front left motor
#define motorpin2 4 // Direction ch3 back right motor
#define motorpin3 7 // Direction ch4 back left motor
#define speedpin0 5 //Speed Ch1
#define speedpin1 6 //Speed Ch2
#define speedpin2 9 //Speed Ch3
#define speedpin3 10 //Speed Ch4
int count=0;

void setup() {
//the motor control wires are outputs
pinMode (motorpin0, OUTPUT);
pinMode(motorpin1, OUTPUT);
pinMode(motorpin2, OUTPUT);
pinMode(motorpin3, OUTPUT);
//PWM Pins are outputs
pinMode(speedpin0, OUTPUT);
pinMode(speedpin1, OUTPUT);
pinMode(speedpin2, OUTPUT);
pinMode(speedpin3, OUTPUT);

}

void loop() {
 
    analogWrite(speedpin0,255);
    analogWrite(speedpin1,255);
    analogWrite(speedpin2,255);
    analogWrite(speedpin3,255);
   
  switch (count)
  {
    case 0: //forward
    digitalWrite(motorpin0,1);
    digitalWrite(motorpin1,1);
    digitalWrite(motorpin2,1);
    digitalWrite(motorpin3,1);
    delay(10000);
    count++;
    break;
   
     case 1: //Turn right
   
    analogWrite(speedpin0,50);
    analogWrite(speedpin2,50);
   
    digitalWrite(motorpin0,1);
    digitalWrite(motorpin1,1);
    digitalWrite(motorpin2,1);
    digitalWrite(motorpin3,1);
    delay(1200);
    count++;
    break;
   
    case 2: //backward
   
    digitalWrite(motorpin0,0);
    digitalWrite(motorpin1,0);
    digitalWrite(motorpin2,0);
    digitalWrite(motorpin3,0);
    delay (5000);
    count++;
    break;
   
   
    case 3: //Turn left
   
    analogWrite(speedpin1,50);
    analogWrite(speedpin3,50);
   
    digitalWrite(motorpin0,1);
    digitalWrite(motorpin1,1);
    digitalWrite(motorpin2,1);
    digitalWrite(motorpin3,1);
    delay(1200);
    count++;
    break;
}
}



Ill replace the count with the incoming command to move the vehicle as requested, im not using any encoders, also to rotate the vehicle i used the PWM, by reducing the cycle from 255 to 50 on right motoros to move it right, vice versa for the left.

I Like your idea of how to handle the direction of the rover, I am doing the same , but I need to find out how I can use my joystick ( diy remote) as a double use I want to control the speed of my rover by the amount you push on the joystick, so when you press it forward 1mm it gives you very slow speed , but full and it gives you high speed but at the same time it needs to take direction into account.