RoboticsGeneral

Romeo BLE mini 'reverse' command

userHead Account cancelled 2018-04-22 11:19:23 2110 Views0 Replies
Hi, I'm using the Romeo BLE mini with the following basic code.
The reverse command only makes the motor to run slower instead of switching direction. Any idea why?

#include <Romeo_m.h>
const int IR1=2;
const int IR2=4;
int IRRead1=0;
int IRRead2=0;
void setup(void)
{
Romeo_m.Initialise();
pinMode(IR1,INPUT);
pinMode(IR2,INPUT);
Serial.begin(115200); //Set Serial Baud
}
void loop(void)
{
char val;
//IR();
if(Serial.available()>0)
{
val = Serial.read();
}
switch(val){
case 'a'://Go forward
Romeo_m.motorControl(Forward,200,Forward,200);
break;
case'b'://Go back
Romeo_m.motorControl(Reverse,100,Reverse,100);
break;
case'c'://Turn left
Romeo_m.motorControl(Forward,100,Reverse,100);
break;
case'd'://Turn right
Romeo_m.motorControl(Reverse,200,Forward,100);
break;
case'e'://Stop
Romeo_m.motorStop();
break;
default: break;
}
}

void IR()
{
IRRead1=digitalRead(IR1);
IRRead2=digitalRead(IR2);
if((IRRead1==0)||(IRRead2==0))
Romeo_m.motorStop();
}