SOLVED: Two servos not working simultaneously


I am trying to set two servomotors at pin 9 and 10 of Arduino Pro at the same time. Unfortunately, only the
second command is working from the graphical programming code. On the other side, corresponding arduino
code is OK and also after upload it works as assumed. Any idea how to make it work also from graphical language?

Version windows 3.0.
Board: arduino Pro 328P

Corresponding program

#include <Arduino.h>
#include <Wire.h>
#include <Servo.h>
#include <SoftwareSerial.h>

double angle_rad = PI/180.0;
double angle_deg = 180.0/PI;
Servo servo_10;
Servo servo_9;

void setup(){

void loop(){


That is strange. Try putting in a short delay between the two to see if there is some timing issue. I would have assumed that using the blocks in mBlock should net the same code when running via the PC but maybe not.

Have you tried pulling the one block out and double clicking it alone?


Unfortunately, this is not the timing issue, and I also tested the blocks alone. Each one works alone, but
two servos at the same time are impossible. Any other command will cancel the previous one. This is not the
case in the Arduino code. But there is a difference, because the graphical language is not compiled and uploaded,
instead it somehow communicates with the driver in the processor.


Isn’t the problem in the firmware? The graphical representation of the Servo command for the Arduino is different from those at mBot. There is no SLOT parameter, so the firmware reads the slot value with the value of the angle and later
the real value cannot be read. Do you think am I looking in right direction?

case SERVO:{
     int slot = readBuffer(7);
     pin = slot==1?mePort[port].s1:mePort[port].s2;
     int v = readBuffer(8);
     Servo sv = servos[searchServoPin(pin)];



Yes, the problem is in the firmware. Firmware defines only single Servo object and even you use two “Set servo pin” blocks, it always attach servo to the actual pin. So if you have two servos, says one at pin 9 and second at pin 10, first call will call sv.attach(9) plus sv.write(value) and second call will reattach sv.attach(10) which also stops the servo at pin9 and only the second servo will run.

I solved the problem for myself by dirty hack: I defined two new objects in firmware: ServoL and ServoR, and I am testing whether the command is related to one of this servos. If not, nothing is changed. If yes, then commands with appropriate servo is executed.

Above mentioned problem will not appear when uploading the text code to arduino, as there is an appropriate number of objects created.


Cool! Thanks for taking the time. I’m thinking I might have to patch up some extensions on the github site but I have to figure out how it all works first.


can you show the code to view or all firmware?