DAGU ROVER 5 SPIDER 4 CHANNEL ENCODER

Posted on 16/01/2012 by edd120k
Modified on: 13/09/2018
Project
Press to mark as completed
Introduction
This is an automatic import from our previous community platform. Some things can look imperfect.

If you are the original author, please access your User Control Panel and update it.

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, ...


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

 

Flag this post

Thanks for helping to keep our community civil!


Notify staff privately
It's Spam
This post is an advertisement, or vandalism. It is not useful or relevant to the current topic.

You flagged this as spam. Undo flag.Flag Post