Servo issues with bluetooth hc06

HI, i connect board hc06 to arduino, and with my smarthphone i use blink for command a servo.
But the servo don’t work. The connection bluetooth is ok.
what do i do? the servo with another skwtch work. i think that the problem is in this code.
in blink i use the button with pin v5 and the value is 0 to 2000.


#define BLYNK_USE_DIRECT_CONNECT

// You could use a spare Hardware Serial on boards that have it (like Mega)
#include <SoftwareSerial.h>
SoftwareSerial DebugSerial(2, 3); // RX, TX
#include <Servo.h>
#include <BlynkSimpleSerialBLE.h>
#define BLYNK_PRINT Serial


// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "mycode";

Servo servo2;


BLYNK_WRITE(V5)
{
  
  servo2.write(param.asInt());
}

void setup()
{
  // Debug console
  DebugSerial.begin(9600);

  // Blynk will work through Serial
  // 9600 is for HC-06. For HC-05 default speed is 38400
  // Do not read or write this serial manually in your sketch
  Serial.begin(9600);
  Blynk.begin(Serial, auth);

   servo2.attach(5);
   
}

void loop()
{
  Blynk.run();
}

I needed to edit your code to format it for proper viewing… in future please post code within this format:

As for your setup… what are you trying to do here?

Servos (using the servo library) take a range of 0-180 (some prefer 0-170)

And you should be using a slider, set for those ranges, for full control, not a button (although that will work for just switching between two positions… but nothing higher than 180.

Also, I don’t think you need this line: #define BLYNK_USE_DIRECT_CONNECT (at least I didn’t)

It does not work even if I put 180. the motor is a rotation continue

If it is a servo modified for continuous rotation then stop is usually around the mid point 90 and left/right is either side with speed rising until limit of 0 or 180 is met.

If it is an actual DC motor, then you need a controller board, not direct drive from digital pin.

This is all I require to get a standard servo to work on my Arduino, using Bluetooth:


#define BLYNK_PRINT Serial // Debug console
#include <SoftwareSerial.h>
#include <BlynkSimpleSerialBLE.h>
#include <Servo.h>
char auth[] = "762f6b018xxxxxxxxxxxxxx6eafdfaf9b";
SoftwareSerial SerialBLE(2, 3); // RX TX on Bluetooth
int servoPin = 11;
int SrvoButtonState = 0;
int SrvoPos;
Servo myservo;


void setup()
{
  pinMode(11, OUTPUT); // Servo Pin
  myservo.attach(servoPin);

  Serial.begin(9600);  // Debug console
  Serial.println("Waiting for connections...");

  SerialBLE.begin(9600); // BT connection
  Blynk.begin(SerialBLE, auth);
  Serial.println("Connected with Bluetooth!");
}



BLYNK_WRITE(V0) // Servo Function with button set 1 & 180
{
  SrvoButtonState = param.asInt();
  if (SrvoButtonState == 0) {
    myservo.write(0);
    Blynk.virtualWrite(V6, 0);
  } else if (SrvoButtonState == 1) {
    myservo.write(180);
    Blynk.virtualWrite(V6, 180);
  } // END else if
} // END Function

BLYNK_WRITE(V1) // Servo Function with Slider set 0-180
{
  SrvoPos = param.asInt();
  myservo.write(SrvoPos);
} // END Function


void loop()
{
  Blynk.run();
  timer.run();
}