0

The board is the RoMeo BLE V 1.0 and I have set the board to Arduino UNO on the board part of the arduino IDE, as I cannot find the RoMeo Board.

This is the code for the motors.

``int speedPin_M1 = 5;     //M1 Speed Control
int speedPin_M2 = 6;     //M2 Speed Control
int directionPin_M1 = 4;     //M1 Direction Control
int directionPin_M2 = 7;     //M1 Direction Control

void setup(){

}

void loop(){
    carAdvance(150,150);
    delay(1000);
    carBack(150,150);
    delay(1000);
    carTurnLeft(150,150);
    delay(1000);
    carTurnRight(150,150);
    delay(1000);
}

void carStop(){                 //  Motor Stop
  digitalWrite(speedPin_M2,0);
  digitalWrite(directionPin_M1,LOW);
  digitalWrite(speedPin_M1,0);
  digitalWrite(directionPin_M2,LOW);
}

void carTurnLeft(int leftSpeed,int rightSpeed){         //Turn Left
  analogWrite (speedPin_M2,leftSpeed);              //PWM Speed Control
  digitalWrite(directionPin_M1,LOW);
  analogWrite (speedPin_M1,rightSpeed);
  digitalWrite(directionPin_M2,HIGH);
}

void carTurnRight(int leftSpeed,int rightSpeed){        //Turn Right
  analogWrite (speedPin_M2,leftSpeed);
  digitalWrite(directionPin_M1,HIGH);
  analogWrite (speedPin_M1,rightSpeed);
  digitalWrite(directionPin_M2,LOW);
}

void carBack(int leftSpeed,int rightSpeed){             //Move backward
  analogWrite (speedPin_M2,leftSpeed);
  digitalWrite(directionPin_M1,LOW);
  analogWrite (speedPin_M1,rightSpeed);
  digitalWrite(directionPin_M2,LOW);
}
void carAdvance(int leftSpeed,int rightSpeed){          //Move forward
  analogWrite (speedPin_M2,leftSpeed);
  digitalWrite(directionPin_M1,HIGH);
  analogWrite (speedPin_M1,rightSpeed);
  digitalWrite(directionPin_M2,HIGH);
}

After I upload the code, nothing happens. The boards light blinks and then after that nothing occurs. How do I get the Motors moving according to the code in the loop?

  • As I read the documentation I found this: "Please turn OFF the Motor Power Switch, when you debug the motor with USB port." Meaning, that the motors cannot run from USB, since it cannot provide enough current. Upload your code with the Motor Power switch in OFF state. Then take the board out of your USB port and connect the external power supply to Vin. Then turn on the Motor Power Switch. – chrisl May 3 '19 at 8:54
  • Please try that, and if it is working, I will write a formal answer to your question – chrisl May 3 '19 at 8:54
  • So these are the specific steps that I took. Plugged the usb in with the battery supply off. Uploaded the code, unplugged the usb then turned the battery supply for the motors on. After that, nothing occurs. – Yaken May 3 '19 at 23:22
  • Okay, so I have got this code working which prints hello when pressing the "z" key BUT the motors do not respond when I send "w, a, s, d" keys through the serial monitor. – Yaken May 3 '19 at 23:37
  • 1. Your code does not read any data from serial, so it cannot react to anything. The motors should start running directly, since thats what your code says. 2. Have you used the motor power switch and the motor control jumper set to the right position, as described in the documentation, that I linked? – chrisl May 4 '19 at 7:14
0

To formulate my comments as answer:

Your board has some features involving the motors/servos:

  1. Since the PCs USB port cannot provide enough current for the motors, they can be switched off wit the Motor Power Switch. It has to be set to OFF, when you connect the board to an USB port. For operating the motors the board needs it's own power supply (a battery in your case), which can provide enough current. So in this case, you have to switch the Motor Power Switch to ON, to enable the motor drivers. Attention: If you turn on the motors while being connected to the USB port, you can damage your board and also your USB port.

  2. The motors are connected to the pins 4, 5, 6 and 7. If you don't need the motors, you can use these pins for other purposes. For this, the board let's you disconnect the motor driver from these pins. If the jumpers, that are marked with "Motor Control Terminal Jumpers" in the image on this documentation page, are inserted onto the jumper pin pairs (in the image they are already inserted), the motor drivers will be connected to the mentioned pins. If the jumpers are not inserted there, the motors will not work, since they are not connected to the controlling pins.


Note, that you need to use pinMode(pin_number, OUTPUT); in the setup() function for all pins, that you want to use digitalWrite() on, because only this way, the corresponding pin will be set to an output (can only then output a digital signal on digitalWrite()). analogWrite() will configure the corresponding pin for you, but it is a good practice to set it as OUTPUT in setup anyway, to make it clear for readers, that this pin is an output.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.