I have a strange issue when i use blynk via bluetooth to control my 3 brushless motors.
Indeed, their behaviour is erratic : they seem to respond to my command (or not) but they also can move on their own for a short period of time (100 ms) and then stop.
I must say I’m confused about where the problem is. I have tested the motors and they work just fine when i command them with the serial monitor, without blynk.
Is something interfering ? Am I doing something wrong ?
Here is the code i use with blynk :
I have carried on my investigation and found something interesting.
I have decided to connect only my 3 motors and to unplug my bluetooth card (therefore it’s not responsible for the issues).
Then I use a minimal code :
#define BLYNK_PRINT Serial
#include <SoftwareSerial.h>
SoftwareSerial SwSerial(2, 3);
#include <BlynkSimpleSerialBLE.h>
#include <SoftwareSerial.h>
#include <Servo.h>
char auth[] = "5fb61e3536ef41b389202c0c232e62e1";
SoftwareSerial SerialBLE(2, 3);
Servo left_servo;
Servo middle_servo;
Servo right_servo;
void setup()
{
left_servo.attach(9);
middle_servo.attach(10);
right_servo.attach(11);
delay(15);
left_servo.write(90); //for calibration (90 = neutral position)
middle_servo.write(90);
right_servo.write(90);
delay(10000); //the motors are quiet up to this point
Serial.println("Connection...");
Serial.begin(9600);
SerialBLE.begin(9600);
Blynk.begin(SerialBLE, auth); //IT IS WHERE ALL STARTS !
}
void loop()
{
Blynk.run();
}
Guess what?
The motors are quiet up to the Blynk.begin() function. Since this point, they start doing weird things and more specifically, they move each quickly (100 ms) each time a “connecting…” message is displayed on the serial monitor. How is it possible that Blynk is making my motors move ?
My motors are connected on the 9,10,11 pins and the bluetooth (which is unplugged) is supposed to be connected to the 2,3 pins.
Is my arduino responsible for this weird behaviour ?
I’m even more confused…
Thanks for your help,
I have tried to attach() and detach() my motors each time they receive a new value, but the result is that they don’t move anymore. It’s probably because i’m using a brushless motor and not a real servo, so if i unplug them they will stop spinning (which is not what i want).
Also, i have changed the used pins for my motors to 3,5 and 6 instead of 9, 10 and 11.
I’m reading the related posts, but is there another way to avoid this issue ?
Thanks !