Romeo sample code problem
greetings,
i new , purchased dfrduino romeo v1.1.
i have 2 motors hook m1 , m2.
with default code come romeo
the romeo able turn 2 motors when turned on romeo.
then, come across link
http://www.dfrobot.com/wiki/index.php/dfrduino_romeo-all_in_one_controller_v1.1%28sku:dfr0004%29
and decide give sample codes below try. after compiled , uploaded romeo.
the motor stop working , green light stop blinking well.
no quite sure go there , how start sample codes test out m1 , m2.
would guys provide guidance on how start here.
where can download orginal codes?
what need modify in sample codes these 2 motor working again?
thank much,
t
******************************************************************
//standard pwm dc control
int e1 = 5; //m1 speed control
int e2 = 6; //m2 speed control
int m1 = 4; //m1 direction control
int m2 = 7; //m1 direction control
///for previous romeo, please use these pins.
//int e1 = 6; //m1 speed control
//int e2 = 9; //m2 speed control
//int m1 = 7; //m1 direction control
//int m2 = 8; //m1 direction control
void stop(void) //stop
{
digitalwrite(e1,low);
digitalwrite(e2,low);
}
void advance(char a,char b) //move forward
{
analogwrite (e1,a); //pwm speed control
digitalwrite(m1,high);
analogwrite (e2,b);
digitalwrite(m2,high);
}
void back_off (char a,char b) //move backward
{
analogwrite (e1,a);
digitalwrite(m1,low);
analogwrite (e2,b);
digitalwrite(m2,low);
}
void turn_l (char a,char b) //turn left
{
analogwrite (e1,a);
digitalwrite(m1,low);
analogwrite (e2,b);
digitalwrite(m2,high);
}
void turn_r (char a,char b) //turn right
{
analogwrite (e1,a);
digitalwrite(m1,high);
analogwrite (e2,b);
digitalwrite(m2,low);
}
void setup(void)
{
int i;
for(i=4;i<=7;i++)
pinmode(i, output);
serial.begin(19200); //set baud rate
serial.println("run keyboard control");
}
void loop(void)
{
if(serial.available()){
char val = serial.read();
if(val != -1)
{
switch(val)
{
case 'w'://move forward
advance (255,255); //move forward in max speed
break;
case 's'://move backward
back_off (255,255); //move in max speed
break;
case 'a'://turn left
turn_l (100,100);
break;
case 'd'://turn right
turn_r (100,100);
break;
case 'z':
serial.println("hello");
break;
case 'x':
stop();
break;
}
}
else stop();
}
}
*****************************************************************
i new , purchased dfrduino romeo v1.1.
i have 2 motors hook m1 , m2.
with default code come romeo
the romeo able turn 2 motors when turned on romeo.
then, come across link
http://www.dfrobot.com/wiki/index.php/dfrduino_romeo-all_in_one_controller_v1.1%28sku:dfr0004%29
and decide give sample codes below try. after compiled , uploaded romeo.
the motor stop working , green light stop blinking well.
no quite sure go there , how start sample codes test out m1 , m2.
would guys provide guidance on how start here.
where can download orginal codes?
what need modify in sample codes these 2 motor working again?
thank much,
t
******************************************************************
//standard pwm dc control
int e1 = 5; //m1 speed control
int e2 = 6; //m2 speed control
int m1 = 4; //m1 direction control
int m2 = 7; //m1 direction control
///for previous romeo, please use these pins.
//int e1 = 6; //m1 speed control
//int e2 = 9; //m2 speed control
//int m1 = 7; //m1 direction control
//int m2 = 8; //m1 direction control
void stop(void) //stop
{
digitalwrite(e1,low);
digitalwrite(e2,low);
}
void advance(char a,char b) //move forward
{
analogwrite (e1,a); //pwm speed control
digitalwrite(m1,high);
analogwrite (e2,b);
digitalwrite(m2,high);
}
void back_off (char a,char b) //move backward
{
analogwrite (e1,a);
digitalwrite(m1,low);
analogwrite (e2,b);
digitalwrite(m2,low);
}
void turn_l (char a,char b) //turn left
{
analogwrite (e1,a);
digitalwrite(m1,low);
analogwrite (e2,b);
digitalwrite(m2,high);
}
void turn_r (char a,char b) //turn right
{
analogwrite (e1,a);
digitalwrite(m1,high);
analogwrite (e2,b);
digitalwrite(m2,low);
}
void setup(void)
{
int i;
for(i=4;i<=7;i++)
pinmode(i, output);
serial.begin(19200); //set baud rate
serial.println("run keyboard control");
}
void loop(void)
{
if(serial.available()){
char val = serial.read();
if(val != -1)
{
switch(val)
{
case 'w'://move forward
advance (255,255); //move forward in max speed
break;
case 's'://move backward
back_off (255,255); //move in max speed
break;
case 'a'://turn left
turn_l (100,100);
break;
case 'd'://turn right
turn_r (100,100);
break;
case 'z':
serial.println("hello");
break;
case 'x':
stop();
break;
}
}
else stop();
}
}
*****************************************************************
thank everyone. studied sample codes , understand now.
thanks again.
t
thanks again.
t
Arduino Forum > Using Arduino > Programming Questions > Romeo sample code problem
arduino
Comments
Post a Comment