(P-BOT) How to control the Motors?

THE MoTOR DRIVER CIRCUIT

MOTOR PIN CONNECTIONS


D10 M1DIR Motor 1 Direction Control Digital I/O 8
D11 M1RUN Motor 1 Run Control Digital I/O 9
D12 M2RUN Motor 2 Run Control Digital I/O 10
D13 M2DIR Motor 2 Direction Control Digital I/O 11

THE CODES

// Move Forward
Ardublock Motor Forward Direction

void setup()
{
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
}
void loop()
{
digitalWrite(8, HIGH);
digitalWrite(9, HIGH);
digitalWrite(10, HIGH);
digitalWrite(11, HIGH);
delay(1000);
}


// Reverse
Ardublock Motor Reverse Direction

void setup()
{
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
}
void loop()
{
digitalWrite(8, LOW);
digitalWrite(9, HIGH);
digitalWrite(10, HIGH);
digitalWrite(11, LOW);
delay(1000);
}


// Turn Right
Ardublock Motor Turn Right

void setup()
{
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
}
void loop()
{
digitalWrite(8, HIGH);
digitalWrite(9, LOW);
digitalWrite(10, HIGH);
digitalWrite(11, HIGH);
delay(1000);
}


// Turn Left
Ardublock Motor Turn Left

void setup()
{
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
}
void loop()
{
digitalWrite(8, HIGH);
digitalWrite(9, HIGH);
digitalWrite(10, LOW);
digitalWrite(11, HIGH);
delay(1000);
}


// Stop
Ardublock Motor Full Stop

void setup()
{
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
}
void loop()
{
digitalWrite(8, LOW);
digitalWrite(9, LOW);
digitalWrite(10, LOW);
digitalWrite(11, LOW);
delay(1000);
}


SPEED CONTROL

// Slow Down
Ardublock Motor Speeds are Slow

void setup()
{
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
}
void loop()
{
analogWrite(8, HIGH);
analogWrite(9, 100);
analogWrite(10, 100);
analogWrite(11, HIGH);
}


// FULL SPEED
Ardublock Motors Full Speed

void setup()
{
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
}
void loop()
{
analogWrite(8, HIGH);
analogWrite(9, 100);
analogWrite(10, 100);
analogWrite(11, HIGH);
}

Leave a Reply

Your email address will not be published. Required fields are marked *