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);
}

 


This is a companion discussion topic for the original entry at https://community.robotshop.com/robots/show/dagu-rover-5-spider-4-channel-encoder

It seems there is an

It seems there is an intermittent problem with the spider controller I have a red flashing light sounding as if the motors are trying to move, it does this randomly

Check if direction pin

Check if direction pin should be digital? I would have thought that direction would be set with just a 0 or a 1.

Thanyou for your replys I

Thanyou for your replys I will change the code to digitalwrite today, the batteries im using are 1.5v aa x 6 in the holder that came with the dagu chassis- I will also try changing the wire to a thicker gage as I read one of your posts on this oddbot. Is 0=LOW and 1=HIGH thanks again for your help

Yes0 = LOW = OFF = 0V1 =

Yes

0 = LOW = OFF = 0V

1 = HIGH = ON = +5V 

thanks very much have put

thanks very much have put thicker leads on the battery now and replaced with nimh, works sweet as a nut thanks oddbot

µC Controllerboard ??

What is this Controllerbaord? An Arduino Mega 2560?

I thank for an answer!
Oderlachs

Many many thanks for the

Many many thanks for the information!
OL