Forum >Control Motors and Servos on Romeo BLE mini V2
Bluno General Arduino

Control Motors and Servos on Romeo BLE mini V2

userHead Account cancelled 2019-09-28 23:59:14 2898 Views1 Replies
Hi,

I am trying to control 2 motors and 4 servos with the Romeo BLE mini V2.0. I used the sample code for Standard PWM DC control from the Romeo wiki page (https://wiki.dfrobot.com/Romeo_BLE_mini ... KU_DFR0351) and the code for the wobbly penguin project (https://www.dfrobot.com/blog-694.html) for servo control.

Just combining the code works in principle, I can control the motors and servos, however, I also get interference, meaning that some of the servos move erratically when I control the motors.

Unfortunately, I do not really understand the pinMode and digitalWrite commands that are used in the two setup functions for these projects:

for the motor control:
Code: Select all
void setup(void)
{
int i;
for(i=4;i<=7;i++)
pinMode(i, OUTPUT);
Serial.begin(9600); //Set Baud Rate
Serial.println("Run keyboard control");
}
for the servo control:
Code: Select all
void setup() {
pinMode(3,OUTPUT);
pinMode(5,OUTPUT);
myservo.attach(2);
digitalWrite(3,LOW);
digitalWrite(5,HIGH);
}
I basically just combined both like this:
Code: Select all
void setup() {
// RomeoBLE board initialization
int i;
for(i=4;i<=7;i++)
pinMode(i, OUTPUT);
pinMode(3,OUTPUT);
pinMode(5,OUTPUT);
myservo1.attach(2);
myservo2.attach(3);
myservo3.attach(8);
myservo4.attach(9);
digitalWrite(3,LOW);
digitalWrite(5,HIGH);
Serial.begin(115200);
}
Could anybody give me a hint what might be going on, or refer me to more detailed information about the setup functions used to control motors and servos using the Romeo BLE mini?