In this program the Robocar turns at full speed. I want it to go full speed going forward and reverse but turn at half speed. I add motor1.setSpeed(127);
motor2.setSpeed(127); to
void left(){
motor1.setSpeed(127);
motor2.setSpeed(127);
motor1.run(FORWARD);
motor2.run(BACKWARD);
}
void right(){
motor1.setSpeed(127);
motor2.setSpeed(127);
motor1.run(BACKWARD);
motor2.run(FORWARD);
}
But after I run these movements all movements are at half speed. My question is how do I get my forward and reverse to reset to full speed. I'm running this program with an App invented 2 and Bluetooth.
Here is the whole program.
#include<AFMotor.h>
AF_DCMotor motor1(1);
AF_DCMotor motor2(2);
char bt='S';
void setup()
{
Serial.begin(9600);
motor1.setSpeed(255);
motor2.setSpeed(255);
Stop();
}
void loop() {
bt=Serial.read();
if(bt=='F')
{
forward();
}
if(bt=='B')
{
backward();
}
if(bt=='L')
{
left();
}
if(bt=='R')
{
right();
}
if(bt=='S')
{
Stop();
}
if(bt=='F')
{
forward();
}
}
void forward()
{
motor1.run(FORWARD);
motor2.run(FORWARD);
}
void backward()
{
motor1.run(BACKWARD);
motor2.run(BACKWARD);
}
void left()
{
motor1.run(FORWARD);
motor2.run(BACKWARD);
}
void right()
{
motor1.run(BACKWARD);
motor2.run(FORWARD);
}
void Stop()
{
motor1.run(RELEASE);
motor2.run(RELEASE);
}