DAGU ROVER 5 SPIDER 4 CHANNEL ENCODER
Hi guys so this is my first robot, finally got it to move properly heres my source code. can you check if it looks ok thanks
int motor1Pin = 6;
int direct1Pin = 55;
int curr1Pin = A0;
int motor2Pin = 5;
int direct2Pin = 58;
int curr2Pin = A3;
int motor3Pin = 4;
int direct3Pin = 61;
int curr3Pin = A6;
int motor4Pin = 3;
int direct4Pin = 64;
int curr4Pin = A9;
void setup()
{
pinMode(motor1Pin, OUTPUT);
pinMode(direct1Pin, OUTPUT);
pinMode(motor2Pin, OUTPUT);
pinMode(direct2Pin, OUTPUT);
pinMode(motor3Pin, OUTPUT);
pinMode(direct3Pin, OUTPUT);
pinMode(motor4Pin, OUTPUT);
pinMode(direct4Pin, OUTPUT);
}
void loop()
{
motorOnThenOffWithSpeed();
}
void motorOnThenOffWithSpeed(){
int onSpeed = 200;
int ondirect = 255;
int onTime = 2500;
int turn180Time = 3500;
int offSpeed = 50;
int offdirect = 0;
int offTime = 1000;
analogWrite(motor1Pin, onSpeed);
analogWrite(direct1Pin, ondirect);
analogWrite(motor2Pin, onSpeed);
analogWrite(direct2Pin, ondirect);
analogWrite(motor3Pin, onSpeed);
analogWrite(direct3Pin, offdirect);
analogWrite(motor4Pin, onSpeed);
analogWrite(direct4Pin, offdirect);
delay(onTime);
analogWrite(motor1Pin, offSpeed);
analogWrite(direct1Pin, ondirect);
analogWrite(motor2Pin, offSpeed);
analogWrite(direct2Pin, ondirect);
analogWrite(motor3Pin, offSpeed);
analogWrite(direct3Pin, offdirect);
analogWrite(motor4Pin, offSpeed);
analogWrite(direct4Pin, offdirect);
delay(offTime);
analogWrite(motor1Pin, onSpeed);
analogWrite(direct1Pin, ondirect);
analogWrite(motor2Pin, onSpeed);
analogWrite(direct2Pin, offdirect);
analogWrite(motor3Pin, onSpeed);
analogWrite(direct3Pin, offdirect);
analogWrite(motor4Pin, onSpeed);
analogWrite(direct4Pin, ondirect);
delay(turn180Time);
}