Hi All,
I'm excited with my new Arduino experience. I got Arduino Romeo (aka. DFDruino / DFRobot),
http://www.dfrobot.com/wiki/index.php?title=DFRduino_Romeo-All_in_one_Controller_(Arduino_Compatible_Atmega_328)_(SKU:DFR0004)
I'm using it to control 1 DC motor. When I ran the code and simulate the Serial communication,
the motor ran for a while. After a few tries and changing the PWM speed, the motor couldn't move anymore.
It has a noise / high sound. Even when I put the PWM speed back to initial speed (100), the motor doesn't move at all.
But when I connect the motor directly to the battery, it works fine. I'm using 9V battery.
After I did much research, I found out it has something to do with de-coupling.
It says I need to put a capacitor.
http://www.thebox.myzen.co.uk/Tutorial/De-coupling.html
The problem is I'm new to arduino.
- Does Arduino Romeo has a capacitor? Please refer to the board picture in the wiki page.
- Where should I put the capacitor on this Arduino Romeo? Can you show me from the board picture. Schema is too difficult for me.
- Does it need to be soldered?
Thanks in advance. I would appreciate your comment and your input.
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=6;i<=9;i++)
pinMode(i, OUTPUT);
Serial.begin(19200); //Set Baud Rate
}
void loop(void)
{
char val = Serial.read();
if(val!=-1)
{
switch(val)
{
case 'w'://Move Forward
advance (100,100); //PWM Speed Control
break;
case 's'://Move Backward
back_off (100,100);
break;
case 'a'://Turn Left
turn_L (100,100);
break;
case 'd'://Turn Right
turn_R (100,100);
break;
}
delay(40);
}
else stop();
}