I have arduino uno with adafruit MotorDriver sheild installed on it. I created a program in which it accepts serial data data drives the motors according to the received serial data. It works fine on COM 3 port but it doesnt work on COM 1 port. In COM 1 port it shows the serial print but doesn;t drive the motors. Actually i want to send data from android phone connected using OTG cable and arduino only supports COM 1 that's why the program doesn't work on android as well. So is there any way by which I can do it on COM1 port as well.
my code:-
#include <AFMotor.h>
AF_DCMotor A(1, MOTOR12_64KHZ);
AF_DCMotor B(2, MOTOR12_64KHZ);
String value="s";
String oldvalue="s";
void setup()
{
// Turn the Serial Protocol ON
Serial.begin(9600);
A.setSpeed(255);
B.setSpeed(255);
A.run(RELEASE);
B.run(RELEASE);
Serial.print("enter value");
}
void loop() {
/* check if data has been sent from the computer: */
while (!Serial.available())
{
}
value= Serial.readString();
if(value.equalsIgnoreCase(oldvalue))
{
Serial.println("You entered old value");
}
else
{
Serial.println("You entered new value");
Serial.println(value);
oldvalue=value;
stopcar();
run(value);
}
}
void stopcar()
{
A.run(RELEASE);
B.run(RELEASE);
Serial.println("Stop called");
}
void run(String para)
{
Serial.println("run called");
Serial.println(value);
if(para.equalsIgnoreCase("F"))
{
A.run(FORWARD);
Serial.print("running forward");
}
else if(para.equalsIgnoreCase("B"))
{
A.run(BACKWARD);
}
else if(para.equalsIgnoreCase("L"))
{
A.run(FORWARD);
B.run(FORWARD);
}
else if(para.equalsIgnoreCase("R"))
{
A.run(FORWARD);
B.run(BACKWARD);
}
else if(para.equalsIgnoreCase("S"))
{
stopcar();
}
}
please HELP.....