APP is Here
#include <AFMotor.h>
#include <Servo.h>
//initial motors pin
AF_DCMotor motor1(1, MOTOR12_1KHZ);
Servo myservo;
char command;
void setup()
{
myservo.attach(10);
myservo.write(115);
Serial.begin(9600);
}
void loop(){
if(Serial.available() > 0){
command = Serial.read();
Stop();
switch(command){
case 'F':
forward();
break;
case 'B':
back();
break;
case 'L':
left();
break;
case 'R':
right();
break;
}
}
}
void forward()
{
motor1.setSpeed(255);
motor1.run(FORWARD);
}
void back()
{
motor1.setSpeed(255);
motor1.run(BACKWARD);
}
void left()
{
motor1.setSpeed(0);
motor1.run(BACKWARD);
myservo.write(0);
}
void right()
{
motor1.setSpeed(0);
motor1.run(FORWARD);
myservo.write(180);
}
void Stop()
{
motor1.setSpeed(0);
motor1.run(RELEASE);
}