BLYNK
BLYNK.IO       📲 GETTING STARTED       📗 DOCS       👉 SKETCH BUILDER

Ios+ ble hm-10

Hello, anyone can help me to explain how use BLE? I want to try use BLE Hm-10 with IOS, but when i want to connect my iphone with BLE, it’s always “can’t connect. please retry or choose another device.” (BLE widget setting). This widget already support for IOS? I used Iphone 6+, IOS 11.2.2, Blynk version 2.13.3, Library release 0.4.10. I’m try connect with LightBlue app, and manually (FTDI and AT-command), that’s works, but not with Blynk. This my sketch:

#define BLYNK_USE_DIRECT_CONNECT

// You could use a spare Hardware Serial on boards that have it (like Mega)
#define SerialBLE Serial2
//#include <SoftwareSerial.h>
//SoftwareSerial DebugSerial(16, 17); // RX, TX

//#define BLYNK_PRINT DebugSerial
#include <BlynkSimpleSerialBLE.h>
#include <Servo.h>

//char blynk
char auth[] = "YOUR AUTH";

//MOTOR PIN
int MOTOR1A = 22;
int MOTOR1B = 23;
int MOTOR2A = 24;
int MOTOR2B = 25;
int MOTOR3A = 30;
int MOTOR3B = 31;
int MOTOR4A = 32;
int MOTOR4B = 33;
int MOTOR5A = 28;
int MOTOR5B = 29;
int MOTOR6A = 26;
int MOTOR6B = 27;

//SPEED PIN
int MOTOR1 = 7;
int MOTOR2 = 6;
int MOTOR3 = 5;
int MOTOR4 = 4;
int MOTOR5 = 3;
int MOTOR6 = 2;

// SERVO
Servo SERVO1, SERVO2, SERVO3, SERVO4, SERVO5, SERVO6;

void setup() {

//BLYNK
// Debug console
  SerialBLE.begin(9600);

  SerialBLE.println("Waiting for connections...");

  // Blynk will work through Serial
  // Do not read or write this serial manually in your sketch
  Serial.begin(9600);
  Blynk.begin(SerialBLE, auth);

// SERVO PIN
SERVO1.attach(13);
SERVO2.attach(12);
SERVO3.attach(11);
SERVO4.attach(10);
SERVO5.attach(9);
SERVO6.attach(8);

//SERVO BEGIN
SERVO1.write(119);
SERVO2.write(37);
SERVO3.write(18);
SERVO4.write(87);
SERVO5.write(117);
SERVO6.write(55);
  
//MOTOR OUTPUT
pinMode(MOTOR1A, OUTPUT);
pinMode(MOTOR1B, OUTPUT);
pinMode(MOTOR2A, OUTPUT);
pinMode(MOTOR2B, OUTPUT);
pinMode(MOTOR3A, OUTPUT);
pinMode(MOTOR3B, OUTPUT);
pinMode(MOTOR4A, OUTPUT);
pinMode(MOTOR4B, OUTPUT);
pinMode(MOTOR5A, OUTPUT);
pinMode(MOTOR5B, OUTPUT);
pinMode(MOTOR6A, OUTPUT);
pinMode(MOTOR6B, OUTPUT);

//SPEED MOTOR OUTPUT
pinMode(MOTOR1, OUTPUT);
pinMode(MOTOR2, OUTPUT);
pinMode(MOTOR3, OUTPUT);
pinMode(MOTOR4, OUTPUT);
pinMode(MOTOR5, OUTPUT);
pinMode(MOTOR6, OUTPUT);

//MOTOR BEGIN
digitalWrite(MOTOR1A, LOW);
digitalWrite(MOTOR1B, LOW);
digitalWrite(MOTOR2A, LOW);
digitalWrite(MOTOR2B, LOW);
digitalWrite(MOTOR3A, LOW);
digitalWrite(MOTOR3B, LOW);
digitalWrite(MOTOR4A, LOW);
digitalWrite(MOTOR4B, LOW);
digitalWrite(MOTOR5A, LOW);
digitalWrite(MOTOR5B, LOW);
digitalWrite(MOTOR6A, LOW);
digitalWrite(MOTOR6B, LOW);
}

void loop() {
  Blynk.run();

}

BLYNK_WRITE(V0) {
  
  const int X_THRESHOLD_LOW = 98; //x: 127 - 30
  const int X_THRESHOLD_HIGH = 158; //x: 127 + 30   

  const int Y_THRESHOLD_LOW = 98; //y: 127 - 30
  const int Y_THRESHOLD_HIGH = 158; //y: 127 + 30
      
  int x_position = param[0].asInt();  //READ BLYNK JOYSTICK x_Position 0-255
  int y_position = param[1].asInt();  //READ BLYNK JOYSTICK y_Position 0-255

  int x_direction;  //VARIABEL JOYSTICK DIRECTION: x= -1, 0, 1
  int y_direction;  //VARIABEL JOYSTICK DIRECTION: y= -1, 0, 1
 
  Serial.print("x_position: ");
  Serial.print(x_position);
  Serial.print("  y_position: ");
  Serial.println(y_position);

//JOYSTICK DIRECTION

  //x_direction = 0;
  //y_direction = 0;

  if (x_position > X_THRESHOLD_HIGH) {
    x_direction = 1;
  } else if (x_position < X_THRESHOLD_LOW) {
    x_direction = -1;
  } else {
    x_direction = 0;
  }
  
  if (y_position > Y_THRESHOLD_HIGH) {
    y_direction = 1;
  } else if (y_position < Y_THRESHOLD_LOW) {
    y_direction = -1;
  } else {
    y_direction = 0;
  }
  
  if (x_direction == -1){

    //x = -1 and y = -1 LEFT BACK
    if (y_direction == -1) {
        Serial.print("JOYSTICK: LEFT DOWN DIRECTION: LEFT BACK");
        Serial.print("  x_direction  ");
        Serial.print(x_direction);
        Serial.print("  y_direction  ");
        Serial.println(y_direction); 

SERVO1.write(145);
SERVO2.write(65);
SERVO3.write(0);
SERVO4.write(85);
SERVO5.write(90);
SERVO6.write(55);
digitalWrite(MOTOR1A, LOW);
digitalWrite(MOTOR1B, HIGH);
digitalWrite(MOTOR2A, LOW);
digitalWrite(MOTOR2B, HIGH);
digitalWrite(MOTOR3A, LOW);
digitalWrite(MOTOR3B, HIGH);
digitalWrite(MOTOR4A, LOW);
digitalWrite(MOTOR4B, HIGH);
digitalWrite(MOTOR5A, LOW);
digitalWrite(MOTOR5B, HIGH);
digitalWrite(MOTOR6A, LOW);
digitalWrite(MOTOR6B, HIGH);
analogWrite(MOTOR1,127);
analogWrite(MOTOR2,255);
analogWrite(MOTOR3,127);
analogWrite(MOTOR4,255);
analogWrite(MOTOR5,127);
analogWrite(MOTOR6,255);
    }
    
    //x = -1 and y = 0 TURN AROUND LEFT
    else if (y_direction == 0) {
        Serial.print("JOYSTICK: LEFT DIRECTION: TURN AROUND LEFT ");
        Serial.print("  x_direction  ");
        Serial.print(x_direction);
        Serial.print("  y_direction  ");
        Serial.println(y_direction);

SERVO1.write(80);
SERVO2.write(85);
SERVO3.write(65);
SERVO4.write(87);
SERVO5.write(80);
SERVO6.write(55);
digitalWrite(MOTOR1A, LOW);
digitalWrite(MOTOR1B, HIGH);
digitalWrite(MOTOR2A, LOW);
digitalWrite(MOTOR2B, HIGH);
digitalWrite(MOTOR3A, HIGH);
digitalWrite(MOTOR3B, LOW);
digitalWrite(MOTOR4A, HIGH);
digitalWrite(MOTOR4B, LOW);
digitalWrite(MOTOR5A, HIGH);
digitalWrite(MOTOR5B, LOW);
digitalWrite(MOTOR6A, LOW);
digitalWrite(MOTOR6B, HIGH);
analogWrite(MOTOR1,255);
analogWrite(MOTOR2,255);
analogWrite(MOTOR3,255);
analogWrite(MOTOR4,255);
analogWrite(MOTOR5,255);
analogWrite(MOTOR6,255);
delay(100);
digitalWrite(MOTOR1A, LOW);
digitalWrite(MOTOR1B, HIGH);
digitalWrite(MOTOR2A, HIGH);
digitalWrite(MOTOR2B, LOW);
digitalWrite(MOTOR3A, LOW);
digitalWrite(MOTOR3B, HIGH);
digitalWrite(MOTOR4A, LOW);
digitalWrite(MOTOR4B, HIGH);
digitalWrite(MOTOR5A, HIGH);
digitalWrite(MOTOR5B, LOW);
digitalWrite(MOTOR6A, HIGH);
digitalWrite(MOTOR6B, LOW );
analogWrite(MOTOR1,100);
analogWrite(MOTOR2,100);
analogWrite(MOTOR3,100);
analogWrite(MOTOR4,100);
analogWrite(MOTOR5,100);
analogWrite(MOTOR6,100);
    }
    
    //x = -1 and y = 1 LEFT FORWARD
    else {
        //y_direction == 1
        Serial.print("JOYSTICK: UP LEFT DIRECTION: LEFT FORWARD");
        Serial.print("  x_direction  ");
        Serial.print(x_direction);
        Serial.print("  y_direction  ");
        Serial.println(y_direction);  

SERVO1.write(145);
SERVO2.write(65);
SERVO3.write(0);
SERVO4.write(85);
SERVO5.write(90);
SERVO6.write(55);
digitalWrite(MOTOR1A, HIGH);
digitalWrite(MOTOR1B, LOW);
digitalWrite(MOTOR2A, HIGH);
digitalWrite(MOTOR2B, LOW);
digitalWrite(MOTOR3A, HIGH);
digitalWrite(MOTOR3B, LOW);
digitalWrite(MOTOR4A, HIGH);
digitalWrite(MOTOR4B, LOW);
digitalWrite(MOTOR5A, HIGH);
digitalWrite(MOTOR5B, LOW);
digitalWrite(MOTOR6A, HIGH);
digitalWrite(MOTOR6B, LOW);
analogWrite(MOTOR1,127);
analogWrite(MOTOR2,255);
analogWrite(MOTOR3,127);
analogWrite(MOTOR4,127);
analogWrite(MOTOR5,255);
analogWrite(MOTOR6,255);
    }
  }    

  else if (x_direction == 0){

    //x = 0 and y = -1 BACK
    if (y_direction == -1) {
        Serial.print("JOYSTICK: DOWN DIRECTION: BACK");
        Serial.print("  x_direction  ");
        Serial.print(x_direction);
        Serial.print("  y_direction  ");
        Serial.println(y_direction);

SERVO1.write(119);
SERVO2.write(37);
SERVO3.write(18);
SERVO4.write(87);
SERVO5.write(117);
SERVO6.write(55);
digitalWrite(MOTOR1A, LOW);
digitalWrite(MOTOR1B, HIGH);
digitalWrite(MOTOR2A, LOW);
digitalWrite(MOTOR2B, HIGH);
digitalWrite(MOTOR3A, LOW);
digitalWrite(MOTOR3B, HIGH);
digitalWrite(MOTOR4A, LOW);
digitalWrite(MOTOR4B, HIGH);
digitalWrite(MOTOR5A, LOW);
digitalWrite(MOTOR5B, HIGH);
digitalWrite(MOTOR6A, LOW);
digitalWrite(MOTOR6B, HIGH);
analogWrite(MOTOR1,255);
analogWrite(MOTOR2,255);
analogWrite(MOTOR3,255);
analogWrite(MOTOR4,255);
analogWrite(MOTOR5,255);
analogWrite(MOTOR6,255);
    }
    
    //x = 0 and y = 0 Stop
    else if (y_direction == 0) {
        Serial.print("JOYSTICK: MID DIRECTION: STOP");
        Serial.print("  x_direction  ");
        Serial.print(x_direction);
        Serial.print("  y_direction  ");
        Serial.println(y_direction);

SERVO1.write(119);
SERVO2.write(37);
SERVO3.write(18);
SERVO4.write(87);
SERVO5.write(117);
SERVO6.write(55);
digitalWrite(MOTOR1A, HIGH);
digitalWrite(MOTOR1B, LOW);
digitalWrite(MOTOR2A, HIGH);
digitalWrite(MOTOR2B, LOW);
digitalWrite(MOTOR3A, LOW);
digitalWrite(MOTOR3B, HIGH);
digitalWrite(MOTOR4A, HIGH);
digitalWrite(MOTOR4B, LOW);
digitalWrite(MOTOR5A, LOW);
digitalWrite(MOTOR5B, HIGH);
digitalWrite(MOTOR6A, LOW);
digitalWrite(MOTOR6B, HIGH);
analogWrite(MOTOR1,255);
analogWrite(MOTOR2,255);
analogWrite(MOTOR3,255);
analogWrite(MOTOR4,255);
analogWrite(MOTOR5,255);
analogWrite(MOTOR6,255);
delay(100);
digitalWrite(MOTOR1A, LOW);
digitalWrite(MOTOR1B, LOW);
digitalWrite(MOTOR2A, LOW);
digitalWrite(MOTOR2B, LOW);
digitalWrite(MOTOR3A, LOW);
digitalWrite(MOTOR3B, LOW);
digitalWrite(MOTOR4A, LOW);
digitalWrite(MOTOR4B, LOW);
digitalWrite(MOTOR5A, LOW);
digitalWrite(MOTOR5B, LOW);
digitalWrite(MOTOR6A, LOW);
digitalWrite(MOTOR6B, LOW);
analogWrite(MOTOR1,0);
analogWrite(MOTOR2,0);
analogWrite(MOTOR3,0);
analogWrite(MOTOR4,0);
analogWrite(MOTOR5,0);
analogWrite(MOTOR6,0);
    }
    
    //x = 0 and y = 1 FORWARD
    else {
        //y_direction == 1
        Serial.print("JOYSTICK: UP DIRECTION: FORWARD");
        Serial.print("  x_direction  ");
        Serial.print(x_direction);
        Serial.print("  y_direction  ");
        Serial.println(y_direction);

SERVO1.write(119);
SERVO2.write(37);
SERVO3.write(18);
SERVO4.write(87);
SERVO5.write(117);
SERVO6.write(55);
digitalWrite(MOTOR1A, HIGH);
digitalWrite(MOTOR1B, LOW);
digitalWrite(MOTOR2A, HIGH);
digitalWrite(MOTOR2B, LOW);
digitalWrite(MOTOR3A, HIGH);
digitalWrite(MOTOR3B, LOW);
digitalWrite(MOTOR4A, HIGH);
digitalWrite(MOTOR4B, LOW);
digitalWrite(MOTOR5A, HIGH);
digitalWrite(MOTOR5B, LOW);
digitalWrite(MOTOR6A, HIGH);
digitalWrite(MOTOR6B, LOW);
analogWrite(MOTOR1,255);
analogWrite(MOTOR2,255);
analogWrite(MOTOR3,255);
analogWrite(MOTOR4,255);
analogWrite(MOTOR5,255);
analogWrite(MOTOR6,255);
    }
  }

  else {//x_direction == 1
  
    //x = 1 and y = -1 BACK RIGHT
    if (y_direction == -1){ 
        Serial.print("JOYSTICK: DOWN RIGHT DIRECTION: BACK RIGHT");
        Serial.print("  x_direction  ");
        Serial.print(x_direction);
        Serial.print("  y_direction  ");
        Serial.println(y_direction);

SERVO1.write(90);
SERVO2.write(10);
SERVO3.write(50);
SERVO4.write(85);
SERVO5.write(155);
SERVO6.write(55);
digitalWrite(MOTOR1A, LOW);
digitalWrite(MOTOR1B, HIGH);
digitalWrite(MOTOR2A, LOW);
digitalWrite(MOTOR2B, HIGH);
digitalWrite(MOTOR3A, LOW);
digitalWrite(MOTOR3B, HIGH);
digitalWrite(MOTOR4A, LOW);
digitalWrite(MOTOR4B, HIGH);
digitalWrite(MOTOR5A, LOW);
digitalWrite(MOTOR5B, HIGH);
digitalWrite(MOTOR6A, LOW);
digitalWrite(MOTOR6B, HIGH);
analogWrite(MOTOR1,255);
analogWrite(MOTOR2,127);
analogWrite(MOTOR3,255);
analogWrite(MOTOR4,255);
analogWrite(MOTOR5,127);
analogWrite(MOTOR6,127);
    }
        
    //x = 1 and y = 0 TURN AROUND RIGHT
    else if (y_direction == 0){ 
        Serial.print("JOYSITCK: RIGHT DIRECTION: TURN AROUND RIGHT");
        Serial.print("  x_direction  ");
        Serial.print(x_direction);
        Serial.print("  y_direction  ");
        Serial.println(y_direction);

SERVO1.write(80);
SERVO2.write(85);
SERVO3.write(65);
SERVO4.write(87);
SERVO5.write(80);
SERVO6.write(55);
digitalWrite(MOTOR1A, LOW);
digitalWrite(MOTOR1B, HIGH);
digitalWrite(MOTOR2A, LOW);
digitalWrite(MOTOR2B, HIGH);
digitalWrite(MOTOR3A, HIGH);
digitalWrite(MOTOR3B, LOW);
digitalWrite(MOTOR4A, HIGH);
digitalWrite(MOTOR4B, LOW);
digitalWrite(MOTOR5A, HIGH);
digitalWrite(MOTOR5B, LOW);
digitalWrite(MOTOR6A, LOW);
digitalWrite(MOTOR6B, HIGH);
analogWrite(MOTOR1,255);
analogWrite(MOTOR2,255);
analogWrite(MOTOR3,255);
analogWrite(MOTOR4,255);
analogWrite(MOTOR5,255);
analogWrite(MOTOR6,255);
delay(100);
digitalWrite(MOTOR1A, HIGH);
digitalWrite(MOTOR1B, LOW);
digitalWrite(MOTOR2A, LOW);
digitalWrite(MOTOR2B, HIGH);
digitalWrite(MOTOR3A, HIGH);
digitalWrite(MOTOR3B, LOW);
digitalWrite(MOTOR4A, HIGH);
digitalWrite(MOTOR4B, LOW);
digitalWrite(MOTOR5A, LOW);
digitalWrite(MOTOR5B, HIGH);
digitalWrite(MOTOR6A, LOW);
digitalWrite(MOTOR6B, HIGH);
analogWrite(MOTOR1,100);
analogWrite(MOTOR2,100);
analogWrite(MOTOR3,100);
analogWrite(MOTOR4,100);
analogWrite(MOTOR5,100);
analogWrite(MOTOR6,100);
    }

    //x = 1 and y = 1 RIGHT FORWARD
    else { 
        //y_direction == 1
        Serial.print("JOYSTICK: UP RIGHT DIRECTION: RIGHT FORWARD"); 
        Serial.print("  x_direction  ");
        Serial.print(x_direction);
        Serial.print("  y_direction  ");
        Serial.println(y_direction);

SERVO1.write(90);
SERVO2.write(10);
SERVO3.write(50);
SERVO4.write(85);
SERVO5.write(155);
SERVO6.write(55);
digitalWrite(MOTOR1A, HIGH);
digitalWrite(MOTOR1B, LOW);
digitalWrite(MOTOR2A, HIGH);
digitalWrite(MOTOR2B, LOW);
digitalWrite(MOTOR3A, HIGH);
digitalWrite(MOTOR3B, LOW);
digitalWrite(MOTOR4A, HIGH);
digitalWrite(MOTOR4B, LOW);
digitalWrite(MOTOR5A, HIGH);
digitalWrite(MOTOR5B, LOW);
digitalWrite(MOTOR6A, HIGH);
digitalWrite(MOTOR6B, LOW);
analogWrite(MOTOR1,255);
analogWrite(MOTOR2,127);
analogWrite(MOTOR3,255);
analogWrite(MOTOR4,255);
analogWrite(MOTOR5,127);
analogWrite(MOTOR6,127);
        }
  }
}

BLYNK_WRITE(V1) //RIGHT
{
  int pinValue = param.asInt(); // assigning incoming value from pin V3 to a variable
  Serial.print("RIGHT: ");
  Serial.println(pinValue);
  if(pinValue == 1) {
    
SERVO1.write(32);
SERVO2.write(127);
SERVO3.write(105);
SERVO4.write(0);
SERVO5.write(27);
SERVO6.write(145);
digitalWrite(MOTOR1A, LOW);
digitalWrite(MOTOR1B, HIGH);
digitalWrite(MOTOR2A, LOW);
digitalWrite(MOTOR2B, HIGH);
digitalWrite(MOTOR3A, HIGH);
digitalWrite(MOTOR3B, LOW);
digitalWrite(MOTOR4A, LOW);
digitalWrite(MOTOR4B, HIGH);
digitalWrite(MOTOR5A, HIGH);
digitalWrite(MOTOR5B, LOW);
digitalWrite(MOTOR6A, LOW);
digitalWrite(MOTOR6B, HIGH);
analogWrite(MOTOR1,255);
analogWrite(MOTOR2,255);
analogWrite(MOTOR3,255);
analogWrite(MOTOR4,255);
analogWrite(MOTOR5,255);
analogWrite(MOTOR6,255);
delay(500);
digitalWrite(MOTOR1A, LOW);
digitalWrite(MOTOR1B, HIGH);
digitalWrite(MOTOR2A, HIGH);
digitalWrite(MOTOR2B, LOW);
digitalWrite(MOTOR3A, HIGH);
digitalWrite(MOTOR3B, LOW);
digitalWrite(MOTOR4A, LOW);
digitalWrite(MOTOR4B, HIGH);
digitalWrite(MOTOR5A, LOW);
digitalWrite(MOTOR5B, HIGH);
digitalWrite(MOTOR6A, HIGH);
digitalWrite(MOTOR6B, LOW);
analogWrite(MOTOR1,128);
analogWrite(MOTOR2,128);
analogWrite(MOTOR3,128);
analogWrite(MOTOR4,128);
analogWrite(MOTOR5,128);
analogWrite(MOTOR6,128);
  }
    
  if(pinValue == 0) {

//STOP    
SERVO1.write(119);
SERVO2.write(37);
SERVO3.write(18);
SERVO4.write(87);
SERVO5.write(117);
SERVO6.write(55);
digitalWrite(MOTOR1A, HIGH);
digitalWrite(MOTOR1B, LOW);
digitalWrite(MOTOR2A, HIGH);
digitalWrite(MOTOR2B, LOW);
digitalWrite(MOTOR3A, LOW);
digitalWrite(MOTOR3B, HIGH);
digitalWrite(MOTOR4A, HIGH);
digitalWrite(MOTOR4B, LOW);
digitalWrite(MOTOR5A, LOW);
digitalWrite(MOTOR5B, HIGH);
digitalWrite(MOTOR6A, LOW);
digitalWrite(MOTOR6B, HIGH);
analogWrite(MOTOR1,255);
analogWrite(MOTOR2,255);
analogWrite(MOTOR3,255);
analogWrite(MOTOR4,255);
analogWrite(MOTOR5,255);
analogWrite(MOTOR6,255);
delay(300);
digitalWrite(MOTOR1A, LOW);
digitalWrite(MOTOR1B, LOW);
digitalWrite(MOTOR2A, LOW);
digitalWrite(MOTOR2B, LOW);
digitalWrite(MOTOR3A, LOW);
digitalWrite(MOTOR3B, LOW);
digitalWrite(MOTOR4A, LOW);
digitalWrite(MOTOR4B, LOW);
digitalWrite(MOTOR5A, LOW);
digitalWrite(MOTOR5B, LOW);
digitalWrite(MOTOR6A, LOW);
digitalWrite(MOTOR6B, LOW);
analogWrite(MOTOR1,0);
analogWrite(MOTOR2,0);
analogWrite(MOTOR3,0);
analogWrite(MOTOR4,0);
analogWrite(MOTOR5,0);
analogWrite(MOTOR6,0);
  }
}

BLYNK_WRITE(V2) //LEFT
{
  int pinValue = param.asInt(); // assigning incoming value from pin V3 to a variable
  Serial.print("LEFT: ");
  Serial.println(pinValue);
  if(pinValue == 1) {
    
SERVO1.write(32);
SERVO2.write(127);
SERVO3.write(105);
SERVO4.write(0);
SERVO5.write(27);
SERVO6.write(145);
digitalWrite(MOTOR1A, LOW);
digitalWrite(MOTOR1B, HIGH);
digitalWrite(MOTOR2A, LOW);
digitalWrite(MOTOR2B, HIGH);
digitalWrite(MOTOR3A, HIGH);
digitalWrite(MOTOR3B, LOW);
digitalWrite(MOTOR4A, LOW);
digitalWrite(MOTOR4B, HIGH);
digitalWrite(MOTOR5A, HIGH);
digitalWrite(MOTOR5B, LOW);
digitalWrite(MOTOR6A, LOW);
digitalWrite(MOTOR6B, HIGH);
analogWrite(MOTOR1,255);
analogWrite(MOTOR2,255);
analogWrite(MOTOR3,255);
analogWrite(MOTOR4,255);
analogWrite(MOTOR5,255);
analogWrite(MOTOR6,255);
delay(500);
digitalWrite(MOTOR1A, HIGH);
digitalWrite(MOTOR1B, LOW);
digitalWrite(MOTOR2A, LOW);
digitalWrite(MOTOR2B, HIGH);
digitalWrite(MOTOR3A, LOW);
digitalWrite(MOTOR3B, HIGH);
digitalWrite(MOTOR4A, HIGH);
digitalWrite(MOTOR4B, LOW);
digitalWrite(MOTOR5A, HIGH);
digitalWrite(MOTOR5B, LOW);
digitalWrite(MOTOR6A, LOW);
digitalWrite(MOTOR6B, HIGH);
analogWrite(MOTOR1,128);
analogWrite(MOTOR2,128);
analogWrite(MOTOR3,128);
analogWrite(MOTOR4,128);
analogWrite(MOTOR5,128);
analogWrite(MOTOR6,128);
  }
    
  if(pinValue == 0) {

//STOP    
SERVO1.write(119);
SERVO2.write(37);
SERVO3.write(18);
SERVO4.write(87);
SERVO5.write(117);
SERVO6.write(55);
digitalWrite(MOTOR1A, HIGH);
digitalWrite(MOTOR1B, LOW);
digitalWrite(MOTOR2A, HIGH);
digitalWrite(MOTOR2B, LOW);
digitalWrite(MOTOR3A, LOW);
digitalWrite(MOTOR3B, HIGH);
digitalWrite(MOTOR4A, HIGH);
digitalWrite(MOTOR4B, LOW);
digitalWrite(MOTOR5A, LOW);
digitalWrite(MOTOR5B, HIGH);
digitalWrite(MOTOR6A, LOW);
digitalWrite(MOTOR6B, HIGH);
analogWrite(MOTOR1,255);
analogWrite(MOTOR2,255);
analogWrite(MOTOR3,255);
analogWrite(MOTOR4,255);
analogWrite(MOTOR5,255);
analogWrite(MOTOR6,255);
delay(300);
digitalWrite(MOTOR1A, LOW);
digitalWrite(MOTOR1B, LOW);
digitalWrite(MOTOR2A, LOW);
digitalWrite(MOTOR2B, LOW);
digitalWrite(MOTOR3A, LOW);
digitalWrite(MOTOR3B, LOW);
digitalWrite(MOTOR4A, LOW);
digitalWrite(MOTOR4B, LOW);
digitalWrite(MOTOR5A, LOW);
digitalWrite(MOTOR5B, LOW);
digitalWrite(MOTOR6A, LOW);
digitalWrite(MOTOR6B, LOW);
analogWrite(MOTOR1,0);
analogWrite(MOTOR2,0);
analogWrite(MOTOR3,0);
analogWrite(MOTOR4,0);
analogWrite(MOTOR5,0);
analogWrite(MOTOR6,0);
  }
}

Yes it should work. Did you check this post: A classic one : Arduino + Iphone + nrf8001

Yes, I’m already check that post and following your step to check, but i’m not yet try to set baudrate like Flyingsoon says, and still can’t connect. I used mega 2560 and connected to serial2, in my sketch i try to use hardwareserial, is that the problem? But if i try the example, i’m still can’t connect too.

As long as you have the pins (Serial2 16 & 17) wired correctly RX (pin17) on MEGA to TX on BT and vice versa.

Apparently you can also have a few firmware options on that module… not sure if updating that will help?

http://www.martyncurrey.com/hm-10-bluetooth-4ble-modules/

Yes, already done :grinning:

I’m already update the firmware to v604.

I’m try to connect BLE with FTDI, and i success to comunicate with AT-COMMAND (AT --> OK). That’s possible if i’m try connect to blynk app with that condition? If possible, i still can’t connected :grimacing::grimacing:
My serial monitor says “OK+CONN e0d1f66159d14e589b4327f01a9266fcOK+LOST” when i try to connnect with blynk app.

The IDE serial monitor, plugged into the USB programming port? If so, then that shows that the Mega does seem to be communicating with the App (via the module), and transmitting the Auth Code, albeit briefly.

Is that the same Auth Code as in your Mega’s sketch and in your App’s project?

@Eugene Am I interpreting that correctly? If so, any ideas? iOS issue?

You should not read or write yourself to the serial you pass to Blynk.begin() in your sketch. This way you interfere library <-> app communication. Also, check the following post to remove OK+ prints to serial : https://community.blynk.cc/t/solved-blynk-and-ble-using-hm10-module-ok-conn-problem

@Gunner
No sir, i mean FTDI (TTL converter) not the mega. So i think that’s will never connected to app because no auth code, but i can comunicate to BLE with AT-COMMAND. :grimacing:

If i try to wiring BLE to mega and connected with app, nothing happend in serial monitor. This my step:

  1. I connected my HM-10 VCC to 3.3v and GND to ground (-) PSU, then HM-10 tx to mega rx (pin 17) and rx to mega tx (pin 16).
  2. upload my sketch
#define BLYNK_USE_DIRECT_CONNECT
#define SerialBLE Serial2
#define BLYNK_PRINT SerialBLE
#include <BlynkSimpleSerialBLE.h>
#include <Servo.h>

//char blynk
char auth[] = "YOUR AUTH";

//MOTOR PIN
int MOTOR1A = 22;
int MOTOR1B = 23;
int MOTOR2A = 24;
int MOTOR2B = 25;
int MOTOR3A = 30;
int MOTOR3B = 31;
int MOTOR4A = 32;
int MOTOR4B = 33;
int MOTOR5A = 28;
int MOTOR5B = 29;
int MOTOR6A = 26;
int MOTOR6B = 27;

//SPEED PIN
int MOTOR1 = 7;
int MOTOR2 = 6;
int MOTOR3 = 5;
int MOTOR4 = 4;
int MOTOR5 = 3;
int MOTOR6 = 2;

// SERVO OBJECT
Servo SERVO1, SERVO2, SERVO3, SERVO4, SERVO5, SERVO6;

void setup() {

//BLYNK
// Debug console
  Serial.begin(9600);

  // Blynk will work through Serial
  // Do not read or write this serial manually in your sketch
  SerialBLE.begin(9600);
  Blynk.begin(SerialBLE, auth);

  SerialBLE.println("Waiting for connections...");

// SERVO PIN
SERVO1.attach(13);
SERVO2.attach(12);
SERVO3.attach(11);
SERVO4.attach(10);
SERVO5.attach(9);
SERVO6.attach(8);

//SERVO BEGIN
SERVO1.write(119);
SERVO2.write(37);
SERVO3.write(18);
SERVO4.write(87);
SERVO5.write(117);
SERVO6.write(55);
  
//MOTOR OUTPUT
pinMode(MOTOR1A, OUTPUT);
pinMode(MOTOR1B, OUTPUT);
pinMode(MOTOR2A, OUTPUT);
pinMode(MOTOR2B, OUTPUT);
pinMode(MOTOR3A, OUTPUT);
pinMode(MOTOR3B, OUTPUT);
pinMode(MOTOR4A, OUTPUT);
pinMode(MOTOR4B, OUTPUT);
pinMode(MOTOR5A, OUTPUT);
pinMode(MOTOR5B, OUTPUT);
pinMode(MOTOR6A, OUTPUT);
pinMode(MOTOR6B, OUTPUT);

//SPEED OUTPUT
pinMode(MOTOR1, OUTPUT);
pinMode(MOTOR2, OUTPUT);
pinMode(MOTOR3, OUTPUT);
pinMode(MOTOR4, OUTPUT);
pinMode(MOTOR5, OUTPUT);
pinMode(MOTOR6, OUTPUT);

// MOTOR BEGIN
digitalWrite(MOTOR1A, LOW);
digitalWrite(MOTOR1B, LOW);
digitalWrite(MOTOR2A, LOW);
digitalWrite(MOTOR2B, LOW);
digitalWrite(MOTOR3A, LOW);
digitalWrite(MOTOR3B, LOW);
digitalWrite(MOTOR4A, LOW);
digitalWrite(MOTOR4B, LOW);
digitalWrite(MOTOR5A, LOW);
digitalWrite(MOTOR5B, LOW);
digitalWrite(MOTOR6A, LOW);
digitalWrite(MOTOR6B, LOW);
}

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

BLYNK_WRITE(V0) {
  
  const int X_THRESHOLD_LOW = 98; //x: 127 - 30
  const int X_THRESHOLD_HIGH = 158; //x: 127 + 30   

  const int Y_THRESHOLD_LOW = 98; //y: 127 - 30
  const int Y_THRESHOLD_HIGH = 158; //y: 127 + 30
      
  int x_position = param[0].asInt();  //READ BLYNK JOYSTICK x_Position 0-255
  int y_position = param[1].asInt();  //READ BLYNK JOYSTICK y_Position 0-255

  int x_direction;  //VARIABEL JOYSTICK DIRECTION: x= -1, 0, 1
  int y_direction;  //VARIABEL JOYSTICK DIRECTION: y= -1, 0, 1
 
  Serial.print("x_position: ");
  Serial.print(x_position);
  Serial.print("  y_position: ");
  Serial.println(y_position);

//JOYSTICK DIRECTION

  //x_direction = 0;
  //y_direction = 0;

  if (x_position > X_THRESHOLD_HIGH) {
    x_direction = 1;
  } else if (x_position < X_THRESHOLD_LOW) {
    x_direction = -1;
  } else {
    x_direction = 0;
  }
  
  if (y_position > Y_THRESHOLD_HIGH) {
    y_direction = 1;
  } else if (y_position < Y_THRESHOLD_LOW) {
    y_direction = -1;
  } else {
    y_direction = 0;
  }
  
//ROBOT DIRECTION:
//0,0(STOP); 0,1(FORWARD); 0,-1(BACKWARD); 1,1(FRONT RIGHT); 1,0(TURN AROUND RIGHT); 
//1,-1(BACK RIGHT); -1,0(TURN AROUND LEFT); -1,1(FRONT LEFT); -1,-1(BACK LEFT)

  if (x_direction == -1){

    //x = -1 and y = -1 
    if (y_direction == -1) {
        Serial.print("JOYSTICK: BACK LEFT DIRECTION: BACK LEFT");
        Serial.print("  x_direction  ");
        Serial.print(x_direction);
        Serial.print("  y_direction  ");
        Serial.println(y_direction); 

SERVO1.write(145);
SERVO2.write(65);
SERVO3.write(0);
SERVO4.write(85);
SERVO5.write(90);
SERVO6.write(55);
digitalWrite(MOTOR1A, LOW);
digitalWrite(MOTOR1B, HIGH);
digitalWrite(MOTOR2A, LOW);
digitalWrite(MOTOR2B, HIGH);
digitalWrite(MOTOR3A, LOW);
digitalWrite(MOTOR3B, HIGH);
digitalWrite(MOTOR4A, LOW);
digitalWrite(MOTOR4B, HIGH);
digitalWrite(MOTOR5A, LOW);
digitalWrite(MOTOR5B, HIGH);
digitalWrite(MOTOR6A, LOW);
digitalWrite(MOTOR6B, HIGH);
analogWrite(MOTOR1,127);
analogWrite(MOTOR2,255);
analogWrite(MOTOR3,127);
analogWrite(MOTOR4,255);
analogWrite(MOTOR5,127);
analogWrite(MOTOR6,255);
    }
    
    //x = -1 and y = 0 TURN AROUND LEFT
    else if (y_direction == 0) {
        Serial.print("JOYSTICK: LEFT DIRECTION: TURN AROUND LEFT");
        Serial.print("  x_direction  ");
        Serial.print(x_direction);
        Serial.print("  y_direction  ");
        Serial.println(y_direction);

SERVO1.write(80);
SERVO2.write(85);
SERVO3.write(65);
SERVO4.write(87);
SERVO5.write(80);
SERVO6.write(55);
digitalWrite(MOTOR1A, LOW);
digitalWrite(MOTOR1B, HIGH);
digitalWrite(MOTOR2A, LOW);
digitalWrite(MOTOR2B, HIGH);
digitalWrite(MOTOR3A, HIGH);
digitalWrite(MOTOR3B, LOW);
digitalWrite(MOTOR4A, HIGH);
digitalWrite(MOTOR4B, LOW);
digitalWrite(MOTOR5A, HIGH);
digitalWrite(MOTOR5B, LOW);
digitalWrite(MOTOR6A, LOW);
digitalWrite(MOTOR6B, HIGH);
analogWrite(MOTOR1,255);
analogWrite(MOTOR2,255);
analogWrite(MOTOR3,255);
analogWrite(MOTOR4,255);
analogWrite(MOTOR5,255);
analogWrite(MOTOR6,255);
delay(100);
digitalWrite(MOTOR1A, LOW);
digitalWrite(MOTOR1B, HIGH);
digitalWrite(MOTOR2A, HIGH);
digitalWrite(MOTOR2B, LOW);
digitalWrite(MOTOR3A, LOW);
digitalWrite(MOTOR3B, HIGH);
digitalWrite(MOTOR4A, LOW);
digitalWrite(MOTOR4B, HIGH);
digitalWrite(MOTOR5A, HIGH);
digitalWrite(MOTOR5B, LOW);
digitalWrite(MOTOR6A, HIGH);
digitalWrite(MOTOR6B, LOW );
analogWrite(MOTOR1,100);
analogWrite(MOTOR2,100);
analogWrite(MOTOR3,100);
analogWrite(MOTOR4,100);
analogWrite(MOTOR5,100);
analogWrite(MOTOR6,100);
    }
    
    //x = -1 and y = 1 FRONT LEFT
    else {
        //y_direction == 1
        Serial.print("JOYSTICK: FRONT LEFT DIRECTION: FRONT LEFT");
        Serial.print("  x_direction  ");
        Serial.print(x_direction);
        Serial.print("  y_direction  ");
        Serial.println(y_direction);  

SERVO1.write(145);
SERVO2.write(65);
SERVO3.write(0);
SERVO4.write(85);
SERVO5.write(90);
SERVO6.write(55);
digitalWrite(MOTOR1A, HIGH);
digitalWrite(MOTOR1B, LOW);
digitalWrite(MOTOR2A, HIGH);
digitalWrite(MOTOR2B, LOW);
digitalWrite(MOTOR3A, HIGH);
digitalWrite(MOTOR3B, LOW);
digitalWrite(MOTOR4A, HIGH);
digitalWrite(MOTOR4B, LOW);
digitalWrite(MOTOR5A, HIGH);
digitalWrite(MOTOR5B, LOW);
digitalWrite(MOTOR6A, HIGH);
digitalWrite(MOTOR6B, LOW);
analogWrite(MOTOR1,127);
analogWrite(MOTOR2,255);
analogWrite(MOTOR3,127);
analogWrite(MOTOR4,127);
analogWrite(MOTOR5,255);
analogWrite(MOTOR6,255);
    }
  }    

  else if (x_direction == 0){

    //x = 0 and y = -1 BACK
    if (y_direction == -1) {
        Serial.print("JOYSTICK: BACK DIRECTION: BACK");
        Serial.print("  x_direction  ");
        Serial.print(x_direction);
        Serial.print("  y_direction  ");
        Serial.println(y_direction);

SERVO1.write(119);
SERVO2.write(37);
SERVO3.write(18);
SERVO4.write(87);
SERVO5.write(117);
SERVO6.write(55);
digitalWrite(MOTOR1A, LOW);
digitalWrite(MOTOR1B, HIGH);
digitalWrite(MOTOR2A, LOW);
digitalWrite(MOTOR2B, HIGH);
digitalWrite(MOTOR3A, LOW);
digitalWrite(MOTOR3B, HIGH);
digitalWrite(MOTOR4A, LOW);
digitalWrite(MOTOR4B, HIGH);
digitalWrite(MOTOR5A, LOW);
digitalWrite(MOTOR5B, HIGH);
digitalWrite(MOTOR6A, LOW);
digitalWrite(MOTOR6B, HIGH);
analogWrite(MOTOR1,255);
analogWrite(MOTOR2,255);
analogWrite(MOTOR3,255);
analogWrite(MOTOR4,255);
analogWrite(MOTOR5,255);
analogWrite(MOTOR6,255);
    }
    
    //x = 0 and y = 0 Stop
    else if (y_direction == 0) {
        Serial.print("JOYSTICK: STOP DIRECTION: STOP");
        Serial.print("  x_direction  ");
        Serial.print(x_direction);
        Serial.print("  y_direction  ");
        Serial.println(y_direction);

SERVO1.write(119);
SERVO2.write(37);
SERVO3.write(18);
SERVO4.write(87);
SERVO5.write(117);
SERVO6.write(55);
digitalWrite(MOTOR1A, HIGH);
digitalWrite(MOTOR1B, LOW);
digitalWrite(MOTOR2A, HIGH);
digitalWrite(MOTOR2B, LOW);
digitalWrite(MOTOR3A, LOW);
digitalWrite(MOTOR3B, HIGH);
digitalWrite(MOTOR4A, HIGH);
digitalWrite(MOTOR4B, LOW);
digitalWrite(MOTOR5A, LOW);
digitalWrite(MOTOR5B, HIGH);
digitalWrite(MOTOR6A, LOW);
digitalWrite(MOTOR6B, HIGH);
analogWrite(MOTOR1,255);
analogWrite(MOTOR2,255);
analogWrite(MOTOR3,255);
analogWrite(MOTOR4,255);
analogWrite(MOTOR5,255);
analogWrite(MOTOR6,255);
delay(100);
digitalWrite(MOTOR1A, LOW);
digitalWrite(MOTOR1B, LOW);
digitalWrite(MOTOR2A, LOW);
digitalWrite(MOTOR2B, LOW);
digitalWrite(MOTOR3A, LOW);
digitalWrite(MOTOR3B, LOW);
digitalWrite(MOTOR4A, LOW);
digitalWrite(MOTOR4B, LOW);
digitalWrite(MOTOR5A, LOW);
digitalWrite(MOTOR5B, LOW);
digitalWrite(MOTOR6A, LOW);
digitalWrite(MOTOR6B, LOW);
analogWrite(MOTOR1,0);
analogWrite(MOTOR2,0);
analogWrite(MOTOR3,0);
analogWrite(MOTOR4,0);
analogWrite(MOTOR5,0);
analogWrite(MOTOR6,0);
    }
    
    //x = 0 and y = 1 FRONT
    else {
        //y_direction == 1
        Serial.print("JOYSTICK: FRONT DIRECTION: FRONT");
        Serial.print("  x_direction  ");
        Serial.print(x_direction);
        Serial.print("  y_direction  ");
        Serial.println(y_direction);

SERVO1.write(119);
SERVO2.write(37);
SERVO3.write(18);
SERVO4.write(87);
SERVO5.write(117);
SERVO6.write(55);
digitalWrite(MOTOR1A, HIGH);
digitalWrite(MOTOR1B, LOW);
digitalWrite(MOTOR2A, HIGH);
digitalWrite(MOTOR2B, LOW);
digitalWrite(MOTOR3A, HIGH);
digitalWrite(MOTOR3B, LOW);
digitalWrite(MOTOR4A, HIGH);
digitalWrite(MOTOR4B, LOW);
digitalWrite(MOTOR5A, HIGH);
digitalWrite(MOTOR5B, LOW);
digitalWrite(MOTOR6A, HIGH);
digitalWrite(MOTOR6B, LOW);
analogWrite(MOTOR1,255);
analogWrite(MOTOR2,255);
analogWrite(MOTOR3,255);
analogWrite(MOTOR4,255);
analogWrite(MOTOR5,255);
analogWrite(MOTOR6,255);
    }
  }

  else {//x_direction == 1
  
    //x = 1 and y = -1 BACK RIGHT
    if (y_direction == -1){ 
        Serial.print("JOYSTICK: BACK RIGHT DIRECTION: BACK RIGHT");
        Serial.print("  x_direction  ");
        Serial.print(x_direction);
        Serial.print("  y_direction  ");
        Serial.println(y_direction);

SERVO1.write(90);
SERVO2.write(10);
SERVO3.write(50);
SERVO4.write(85);
SERVO5.write(155);
SERVO6.write(55);
digitalWrite(MOTOR1A, LOW);
digitalWrite(MOTOR1B, HIGH);
digitalWrite(MOTOR2A, LOW);
digitalWrite(MOTOR2B, HIGH);
digitalWrite(MOTOR3A, LOW);
digitalWrite(MOTOR3B, HIGH);
digitalWrite(MOTOR4A, LOW);
digitalWrite(MOTOR4B, HIGH);
digitalWrite(MOTOR5A, LOW);
digitalWrite(MOTOR5B, HIGH);
digitalWrite(MOTOR6A, LOW);
digitalWrite(MOTOR6B, HIGH);
analogWrite(MOTOR1,255);
analogWrite(MOTOR2,127);
analogWrite(MOTOR3,255);
analogWrite(MOTOR4,255);
analogWrite(MOTOR5,127);
analogWrite(MOTOR6,127);
    }
        
    //x = 1 and y = 0 TURN AROUND RIGHT
    else if (y_direction == 0){ 
        Serial.print("JOYSITCK: RIGHT DIRECTION: TURN AROUND RIGHT");
        Serial.print("  x_direction  ");
        Serial.print(x_direction);
        Serial.print("  y_direction  ");
        Serial.println(y_direction);

SERVO1.write(80);
SERVO2.write(85);
SERVO3.write(65);
SERVO4.write(87);
SERVO5.write(80);
SERVO6.write(55);
digitalWrite(MOTOR1A, LOW);
digitalWrite(MOTOR1B, HIGH);
digitalWrite(MOTOR2A, LOW);
digitalWrite(MOTOR2B, HIGH);
digitalWrite(MOTOR3A, HIGH);
digitalWrite(MOTOR3B, LOW);
digitalWrite(MOTOR4A, HIGH);
digitalWrite(MOTOR4B, LOW);
digitalWrite(MOTOR5A, HIGH);
digitalWrite(MOTOR5B, LOW);
digitalWrite(MOTOR6A, LOW);
digitalWrite(MOTOR6B, HIGH);
analogWrite(MOTOR1,255);
analogWrite(MOTOR2,255);
analogWrite(MOTOR3,255);
analogWrite(MOTOR4,255);
analogWrite(MOTOR5,255);
analogWrite(MOTOR6,255);
delay(100);
digitalWrite(MOTOR1A, HIGH);
digitalWrite(MOTOR1B, LOW);
digitalWrite(MOTOR2A, LOW);
digitalWrite(MOTOR2B, HIGH);
digitalWrite(MOTOR3A, HIGH);
digitalWrite(MOTOR3B, LOW);
digitalWrite(MOTOR4A, HIGH);
digitalWrite(MOTOR4B, LOW);
digitalWrite(MOTOR5A, LOW);
digitalWrite(MOTOR5B, HIGH);
digitalWrite(MOTOR6A, LOW);
digitalWrite(MOTOR6B, HIGH);
analogWrite(MOTOR1,100);
analogWrite(MOTOR2,100);
analogWrite(MOTOR3,100);
analogWrite(MOTOR4,100);
analogWrite(MOTOR5,100);
analogWrite(MOTOR6,100);
    }

    //x = 1 and y = 1 FRONT RIGHT
    else { 
        //y_direction == 1
        Serial.print("JOYSTICK: FRONT RIGHT DIRECTION: FRONT RIGHT"); 
        Serial.print("  x_direction  ");
        Serial.print(x_direction);
        Serial.print("  y_direction  ");
        Serial.println(y_direction);

SERVO1.write(90);
SERVO2.write(10);
SERVO3.write(50);
SERVO4.write(85);
SERVO5.write(155);
SERVO6.write(55);
digitalWrite(MOTOR1A, HIGH);
digitalWrite(MOTOR1B, LOW);
digitalWrite(MOTOR2A, HIGH);
digitalWrite(MOTOR2B, LOW);
digitalWrite(MOTOR3A, HIGH);
digitalWrite(MOTOR3B, LOW);
digitalWrite(MOTOR4A, HIGH);
digitalWrite(MOTOR4B, LOW);
digitalWrite(MOTOR5A, HIGH);
digitalWrite(MOTOR5B, LOW);
digitalWrite(MOTOR6A, HIGH);
digitalWrite(MOTOR6B, LOW);
analogWrite(MOTOR1,255);
analogWrite(MOTOR2,127);
analogWrite(MOTOR3,255);
analogWrite(MOTOR4,255);
analogWrite(MOTOR5,127);
analogWrite(MOTOR6,127);
        }
  }
}

BLYNK_WRITE(V1) //RIGHT
{
  int pinValue = param.asInt(); // assigning incoming value from pin V1 to a variable
  Serial.print("RIGHT: ");
  Serial.println(pinValue);
  if(pinValue == 1) {
    
SERVO1.write(32);
SERVO2.write(127);
SERVO3.write(105);
SERVO4.write(0);
SERVO5.write(27);
SERVO6.write(145);
digitalWrite(MOTOR1A, LOW);
digitalWrite(MOTOR1B, HIGH);
digitalWrite(MOTOR2A, LOW);
digitalWrite(MOTOR2B, HIGH);
digitalWrite(MOTOR3A, HIGH);
digitalWrite(MOTOR3B, LOW);
digitalWrite(MOTOR4A, LOW);
digitalWrite(MOTOR4B, HIGH);
digitalWrite(MOTOR5A, HIGH);
digitalWrite(MOTOR5B, LOW);
digitalWrite(MOTOR6A, LOW);
digitalWrite(MOTOR6B, HIGH);
analogWrite(MOTOR1,255);
analogWrite(MOTOR2,255);
analogWrite(MOTOR3,255);
analogWrite(MOTOR4,255);
analogWrite(MOTOR5,255);
analogWrite(MOTOR6,255);
delay(500);
digitalWrite(MOTOR1A, LOW);
digitalWrite(MOTOR1B, HIGH);
digitalWrite(MOTOR2A, HIGH);
digitalWrite(MOTOR2B, LOW);
digitalWrite(MOTOR3A, HIGH);
digitalWrite(MOTOR3B, LOW);
digitalWrite(MOTOR4A, LOW);
digitalWrite(MOTOR4B, HIGH);
digitalWrite(MOTOR5A, LOW);
digitalWrite(MOTOR5B, HIGH);
digitalWrite(MOTOR6A, HIGH);
digitalWrite(MOTOR6B, LOW);
analogWrite(MOTOR1,128);
analogWrite(MOTOR2,128);
analogWrite(MOTOR3,128);
analogWrite(MOTOR4,128);
analogWrite(MOTOR5,128);
analogWrite(MOTOR6,128);
  }
    
  if(pinValue == 0) {

//STOP    
SERVO1.write(119);
SERVO2.write(37);
SERVO3.write(18);
SERVO4.write(87);
SERVO5.write(117);
SERVO6.write(55);
digitalWrite(MOTOR1A, HIGH);
digitalWrite(MOTOR1B, LOW);
digitalWrite(MOTOR2A, HIGH);
digitalWrite(MOTOR2B, LOW);
digitalWrite(MOTOR3A, LOW);
digitalWrite(MOTOR3B, HIGH);
digitalWrite(MOTOR4A, HIGH);
digitalWrite(MOTOR4B, LOW);
digitalWrite(MOTOR5A, LOW);
digitalWrite(MOTOR5B, HIGH);
digitalWrite(MOTOR6A, LOW);
digitalWrite(MOTOR6B, HIGH);
analogWrite(MOTOR1,255);
analogWrite(MOTOR2,255);
analogWrite(MOTOR3,255);
analogWrite(MOTOR4,255);
analogWrite(MOTOR5,255);
analogWrite(MOTOR6,255);
delay(300);
digitalWrite(MOTOR1A, LOW);
digitalWrite(MOTOR1B, LOW);
digitalWrite(MOTOR2A, LOW);
digitalWrite(MOTOR2B, LOW);
digitalWrite(MOTOR3A, LOW);
digitalWrite(MOTOR3B, LOW);
digitalWrite(MOTOR4A, LOW);
digitalWrite(MOTOR4B, LOW);
digitalWrite(MOTOR5A, LOW);
digitalWrite(MOTOR5B, LOW);
digitalWrite(MOTOR6A, LOW);
digitalWrite(MOTOR6B, LOW);
analogWrite(MOTOR1,0);
analogWrite(MOTOR2,0);
analogWrite(MOTOR3,0);
analogWrite(MOTOR4,0);
analogWrite(MOTOR5,0);
analogWrite(MOTOR6,0);
  }
}

BLYNK_WRITE(V2) //LEFT
{
  int pinValue = param.asInt(); // assigning incoming value from pin V2 to a variable
  Serial.print("LEFT: ");
  Serial.println(pinValue);
  if(pinValue == 1) {

SERVO1.write(32);
SERVO2.write(127);
SERVO3.write(105);
SERVO4.write(0);
SERVO5.write(27);
SERVO6.write(145);
digitalWrite(MOTOR1A, LOW);
digitalWrite(MOTOR1B, HIGH);
digitalWrite(MOTOR2A, LOW);
digitalWrite(MOTOR2B, HIGH);
digitalWrite(MOTOR3A, HIGH);
digitalWrite(MOTOR3B, LOW);
digitalWrite(MOTOR4A, LOW);
digitalWrite(MOTOR4B, HIGH);
digitalWrite(MOTOR5A, HIGH);
digitalWrite(MOTOR5B, LOW);
digitalWrite(MOTOR6A, LOW);
digitalWrite(MOTOR6B, HIGH);
analogWrite(MOTOR1,255);
analogWrite(MOTOR2,255);
analogWrite(MOTOR3,255);
analogWrite(MOTOR4,255);
analogWrite(MOTOR5,255);
analogWrite(MOTOR6,255);
delay(500);
digitalWrite(MOTOR1A, HIGH);
digitalWrite(MOTOR1B, LOW);
digitalWrite(MOTOR2A, LOW);
digitalWrite(MOTOR2B, HIGH);
digitalWrite(MOTOR3A, LOW);
digitalWrite(MOTOR3B, HIGH);
digitalWrite(MOTOR4A, HIGH);
digitalWrite(MOTOR4B, LOW);
digitalWrite(MOTOR5A, HIGH);
digitalWrite(MOTOR5B, LOW);
digitalWrite(MOTOR6A, LOW);
digitalWrite(MOTOR6B, HIGH);
analogWrite(MOTOR1,128);
analogWrite(MOTOR2,128);
analogWrite(MOTOR3,128);
analogWrite(MOTOR4,128);
analogWrite(MOTOR5,128);
analogWrite(MOTOR6,128);
  }
    
  if(pinValue == 0) {

//STOP    
SERVO1.write(119);
SERVO2.write(37);
SERVO3.write(18);
SERVO4.write(87);
SERVO5.write(117);
SERVO6.write(55);
digitalWrite(MOTOR1A, HIGH);
digitalWrite(MOTOR1B, LOW);
digitalWrite(MOTOR2A, HIGH);
digitalWrite(MOTOR2B, LOW);
digitalWrite(MOTOR3A, LOW);
digitalWrite(MOTOR3B, HIGH);
digitalWrite(MOTOR4A, HIGH);
digitalWrite(MOTOR4B, LOW);
digitalWrite(MOTOR5A, LOW);
digitalWrite(MOTOR5B, HIGH);
digitalWrite(MOTOR6A, LOW);
digitalWrite(MOTOR6B, HIGH);
analogWrite(MOTOR1,255);
analogWrite(MOTOR2,255);
analogWrite(MOTOR3,255);
analogWrite(MOTOR4,255);
analogWrite(MOTOR5,255);
analogWrite(MOTOR6,255);
delay(300);
digitalWrite(MOTOR1A, LOW);
digitalWrite(MOTOR1B, LOW);
digitalWrite(MOTOR2A, LOW);
digitalWrite(MOTOR2B, LOW);
digitalWrite(MOTOR3A, LOW);
digitalWrite(MOTOR3B, LOW);
digitalWrite(MOTOR4A, LOW);
digitalWrite(MOTOR4B, LOW);
digitalWrite(MOTOR5A, LOW);
digitalWrite(MOTOR5B, LOW);
digitalWrite(MOTOR6A, LOW);
digitalWrite(MOTOR6B, LOW);
analogWrite(MOTOR1,0);
analogWrite(MOTOR2,0);
analogWrite(MOTOR3,0);
analogWrite(MOTOR4,0);
analogWrite(MOTOR5,0);
analogWrite(MOTOR6,0);
  }
}
  1. Open serial monitor
  2. Open app, BLE setting, connect ble device, choose device (my device name is HMSoft)
  3. connecting… and then “Can’t connect. Please retry or choose another device.”
  4. Nothing happend in my serial monitor, just blank. I set “no line ending” or “both NL & CR” and “9600 baud”
  5. The auth code in my app and mega sketch is same

@Eugene
I already used AT+NOTI0 like that post. This widget work with IOS 11.2.2? or i miss something and cause this not working?

The Mega has multiple Hardware UART ports… all independent from each other and thus safe to use simultaneously if programmed as such… but it turns out the OP was not using the Mega in that example with the Auth code anyhow… so… it didn’t mean what I thought it did :stuck_out_tongue:

Thanks anyhow.

I meant serial println statement in the sketch above

Ah Ha!.. good catch…

@JJ11 remove this line… as it might be blocking your BLE connection, as Eugene mentioned.

Still can’t connected when i’m disable

//SerialBLE.println(“Waiting for connections…”);

Well, sorry… I have neither an iPhone nor a HM-10, and have suggested everything i can think of, so I am unable to troubleshoot further.

Perhaps someone else might take a try at this?

It’s ok sir, thank you for your help :grin::grin:

I dont know, i try many people steps, but still can’t connected, maybe i miss something… :grimacing:

Update:
i try to disable

//#define BLYNK_USE_DIRECT_CONNECT

and change

#define BLYNK_PRINT SerialBLE

become

#define BLYNK_PRINT Serial

and my sketch become

//#define BLYNK_USE_DIRECT_CONNECT
#define SerialBLE Serial2
#define BLYNK_PRINT Serial
#include <BlynkSimpleSerialBLE.h>
#include <Servo.h>

//char blynk
char auth[] = "YOUR AUTH";

//MOTOR PIN
int MOTOR1A = 22;
int MOTOR1B = 23;
int MOTOR2A = 24;
int MOTOR2B = 25;
int MOTOR3A = 30;
int MOTOR3B = 31;
int MOTOR4A = 32;
int MOTOR4B = 33;
int MOTOR5A = 28;
int MOTOR5B = 29;
int MOTOR6A = 26;
int MOTOR6B = 27;

//SPEED PIN
int MOTOR1 = 7;
int MOTOR2 = 6;
int MOTOR3 = 5;
int MOTOR4 = 4;
int MOTOR5 = 3;
int MOTOR6 = 2;

// SERVO OBJECT
Servo SERVO1, SERVO2, SERVO3, SERVO4, SERVO5, SERVO6;

void setup() {

//BLYNK
// Debug console
  Serial.begin(9600);

  // Blynk will work through Serial
  // Do not read or write this serial manually in your sketch
  SerialBLE.begin(9600);
  Blynk.begin(SerialBLE, auth);

  //SerialBLE.println("Waiting for connections...");

// SERVO PIN
SERVO1.attach(13);
SERVO2.attach(12);
SERVO3.attach(11);
SERVO4.attach(10);
SERVO5.attach(9);
SERVO6.attach(8);

//SERVO BEGIN
SERVO1.write(119);
SERVO2.write(37);
SERVO3.write(18);
SERVO4.write(87);
SERVO5.write(117);
SERVO6.write(55);
  
//MOTOR OUTPUT
pinMode(MOTOR1A, OUTPUT);
pinMode(MOTOR1B, OUTPUT);
pinMode(MOTOR2A, OUTPUT);
pinMode(MOTOR2B, OUTPUT);
pinMode(MOTOR3A, OUTPUT);
pinMode(MOTOR3B, OUTPUT);
pinMode(MOTOR4A, OUTPUT);
pinMode(MOTOR4B, OUTPUT);
pinMode(MOTOR5A, OUTPUT);
pinMode(MOTOR5B, OUTPUT);
pinMode(MOTOR6A, OUTPUT);
pinMode(MOTOR6B, OUTPUT);

//SPEED OUTPUT
pinMode(MOTOR1, OUTPUT);
pinMode(MOTOR2, OUTPUT);
pinMode(MOTOR3, OUTPUT);
pinMode(MOTOR4, OUTPUT);
pinMode(MOTOR5, OUTPUT);
pinMode(MOTOR6, OUTPUT);

// MOTOR BEGIN
digitalWrite(MOTOR1A, LOW);
digitalWrite(MOTOR1B, LOW);
digitalWrite(MOTOR2A, LOW);
digitalWrite(MOTOR2B, LOW);
digitalWrite(MOTOR3A, LOW);
digitalWrite(MOTOR3B, LOW);
digitalWrite(MOTOR4A, LOW);
digitalWrite(MOTOR4B, LOW);
digitalWrite(MOTOR5A, LOW);
digitalWrite(MOTOR5B, LOW);
digitalWrite(MOTOR6A, LOW);
digitalWrite(MOTOR6B, LOW);
}

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

BLYNK_WRITE(V0) {
  
  const int X_THRESHOLD_LOW = 98; //x: 127 - 30
  const int X_THRESHOLD_HIGH = 158; //x: 127 + 30   

  const int Y_THRESHOLD_LOW = 98; //y: 127 - 30
  const int Y_THRESHOLD_HIGH = 158; //y: 127 + 30
      
  int x_position = param[0].asInt();  //READ BLYNK JOYSTICK x_Position 0-255
  int y_position = param[1].asInt();  //READ BLYNK JOYSTICK y_Position 0-255

  int x_direction;  //VARIABEL JOYSTICK DIRECTION: x= -1, 0, 1
  int y_direction;  //VARIABEL JOYSTICK DIRECTION: y= -1, 0, 1
 
  Serial.print("x_position: ");
  Serial.print(x_position);
  Serial.print("  y_position: ");
  Serial.println(y_position);

//JOYSTICK DIRECTION

  //x_direction = 0;
  //y_direction = 0;

  if (x_position > X_THRESHOLD_HIGH) {
    x_direction = 1;
  } else if (x_position < X_THRESHOLD_LOW) {
    x_direction = -1;
  } else {
    x_direction = 0;
  }
  
  if (y_position > Y_THRESHOLD_HIGH) {
    y_direction = 1;
  } else if (y_position < Y_THRESHOLD_LOW) {
    y_direction = -1;
  } else {
    y_direction = 0;
  }
  
//ROBOT DIRECTION:
//0,0(STOP); 0,1(FORWARD); 0,-1(BACKWARD); 1,1(FRONT RIGHT); 1,0(TURN AROUND RIGHT); 
//1,-1(BACK RIGHT); -1,0(TURN AROUND LEFT); -1,1(FRONT LEFT); -1,-1(BACK LEFT)

  if (x_direction == -1){

    //x = -1 and y = -1 
    if (y_direction == -1) {
        Serial.print("JOYSTICK: BACK LEFT DIRECTION: BACK LEFT");
        Serial.print("  x_direction  ");
        Serial.print(x_direction);
        Serial.print("  y_direction  ");
        Serial.println(y_direction); 

SERVO1.write(145);
SERVO2.write(65);
SERVO3.write(0);
SERVO4.write(85);
SERVO5.write(90);
SERVO6.write(55);
digitalWrite(MOTOR1A, LOW);
digitalWrite(MOTOR1B, HIGH);
digitalWrite(MOTOR2A, LOW);
digitalWrite(MOTOR2B, HIGH);
digitalWrite(MOTOR3A, LOW);
digitalWrite(MOTOR3B, HIGH);
digitalWrite(MOTOR4A, LOW);
digitalWrite(MOTOR4B, HIGH);
digitalWrite(MOTOR5A, LOW);
digitalWrite(MOTOR5B, HIGH);
digitalWrite(MOTOR6A, LOW);
digitalWrite(MOTOR6B, HIGH);
analogWrite(MOTOR1,127);
analogWrite(MOTOR2,255);
analogWrite(MOTOR3,127);
analogWrite(MOTOR4,255);
analogWrite(MOTOR5,127);
analogWrite(MOTOR6,255);
    }
    
    //x = -1 and y = 0 TURN AROUND LEFT
    else if (y_direction == 0) {
        Serial.print("JOYSTICK: LEFT DIRECTION: TURN AROUND LEFT");
        Serial.print("  x_direction  ");
        Serial.print(x_direction);
        Serial.print("  y_direction  ");
        Serial.println(y_direction);

SERVO1.write(80);
SERVO2.write(85);
SERVO3.write(65);
SERVO4.write(87);
SERVO5.write(80);
SERVO6.write(55);
digitalWrite(MOTOR1A, LOW);
digitalWrite(MOTOR1B, HIGH);
digitalWrite(MOTOR2A, LOW);
digitalWrite(MOTOR2B, HIGH);
digitalWrite(MOTOR3A, HIGH);
digitalWrite(MOTOR3B, LOW);
digitalWrite(MOTOR4A, HIGH);
digitalWrite(MOTOR4B, LOW);
digitalWrite(MOTOR5A, HIGH);
digitalWrite(MOTOR5B, LOW);
digitalWrite(MOTOR6A, LOW);
digitalWrite(MOTOR6B, HIGH);
analogWrite(MOTOR1,255);
analogWrite(MOTOR2,255);
analogWrite(MOTOR3,255);
analogWrite(MOTOR4,255);
analogWrite(MOTOR5,255);
analogWrite(MOTOR6,255);
delay(100);
digitalWrite(MOTOR1A, LOW);
digitalWrite(MOTOR1B, HIGH);
digitalWrite(MOTOR2A, HIGH);
digitalWrite(MOTOR2B, LOW);
digitalWrite(MOTOR3A, LOW);
digitalWrite(MOTOR3B, HIGH);
digitalWrite(MOTOR4A, LOW);
digitalWrite(MOTOR4B, HIGH);
digitalWrite(MOTOR5A, HIGH);
digitalWrite(MOTOR5B, LOW);
digitalWrite(MOTOR6A, HIGH);
digitalWrite(MOTOR6B, LOW );
analogWrite(MOTOR1,100);
analogWrite(MOTOR2,100);
analogWrite(MOTOR3,100);
analogWrite(MOTOR4,100);
analogWrite(MOTOR5,100);
analogWrite(MOTOR6,100);
    }
    
    //x = -1 and y = 1 FRONT LEFT
    else {
        //y_direction == 1
        Serial.print("JOYSTICK: FRONT LEFT DIRECTION: FRONT LEFT");
        Serial.print("  x_direction  ");
        Serial.print(x_direction);
        Serial.print("  y_direction  ");
        Serial.println(y_direction);  

SERVO1.write(145);
SERVO2.write(65);
SERVO3.write(0);
SERVO4.write(85);
SERVO5.write(90);
SERVO6.write(55);
digitalWrite(MOTOR1A, HIGH);
digitalWrite(MOTOR1B, LOW);
digitalWrite(MOTOR2A, HIGH);
digitalWrite(MOTOR2B, LOW);
digitalWrite(MOTOR3A, HIGH);
digitalWrite(MOTOR3B, LOW);
digitalWrite(MOTOR4A, HIGH);
digitalWrite(MOTOR4B, LOW);
digitalWrite(MOTOR5A, HIGH);
digitalWrite(MOTOR5B, LOW);
digitalWrite(MOTOR6A, HIGH);
digitalWrite(MOTOR6B, LOW);
analogWrite(MOTOR1,127);
analogWrite(MOTOR2,255);
analogWrite(MOTOR3,127);
analogWrite(MOTOR4,127);
analogWrite(MOTOR5,255);
analogWrite(MOTOR6,255);
    }
  }    

  else if (x_direction == 0){

    //x = 0 and y = -1 BACK
    if (y_direction == -1) {
        Serial.print("JOYSTICK: BACK DIRECTION: BACK");
        Serial.print("  x_direction  ");
        Serial.print(x_direction);
        Serial.print("  y_direction  ");
        Serial.println(y_direction);

SERVO1.write(119);
SERVO2.write(37);
SERVO3.write(18);
SERVO4.write(87);
SERVO5.write(117);
SERVO6.write(55);
digitalWrite(MOTOR1A, LOW);
digitalWrite(MOTOR1B, HIGH);
digitalWrite(MOTOR2A, LOW);
digitalWrite(MOTOR2B, HIGH);
digitalWrite(MOTOR3A, LOW);
digitalWrite(MOTOR3B, HIGH);
digitalWrite(MOTOR4A, LOW);
digitalWrite(MOTOR4B, HIGH);
digitalWrite(MOTOR5A, LOW);
digitalWrite(MOTOR5B, HIGH);
digitalWrite(MOTOR6A, LOW);
digitalWrite(MOTOR6B, HIGH);
analogWrite(MOTOR1,255);
analogWrite(MOTOR2,255);
analogWrite(MOTOR3,255);
analogWrite(MOTOR4,255);
analogWrite(MOTOR5,255);
analogWrite(MOTOR6,255);
    }
    
    //x = 0 and y = 0 Stop
    else if (y_direction == 0) {
        Serial.print("JOYSTICK: STOP DIRECTION: STOP");
        Serial.print("  x_direction  ");
        Serial.print(x_direction);
        Serial.print("  y_direction  ");
        Serial.println(y_direction);

SERVO1.write(119);
SERVO2.write(37);
SERVO3.write(18);
SERVO4.write(87);
SERVO5.write(117);
SERVO6.write(55);
digitalWrite(MOTOR1A, HIGH);
digitalWrite(MOTOR1B, LOW);
digitalWrite(MOTOR2A, HIGH);
digitalWrite(MOTOR2B, LOW);
digitalWrite(MOTOR3A, LOW);
digitalWrite(MOTOR3B, HIGH);
digitalWrite(MOTOR4A, HIGH);
digitalWrite(MOTOR4B, LOW);
digitalWrite(MOTOR5A, LOW);
digitalWrite(MOTOR5B, HIGH);
digitalWrite(MOTOR6A, LOW);
digitalWrite(MOTOR6B, HIGH);
analogWrite(MOTOR1,255);
analogWrite(MOTOR2,255);
analogWrite(MOTOR3,255);
analogWrite(MOTOR4,255);
analogWrite(MOTOR5,255);
analogWrite(MOTOR6,255);
delay(100);
digitalWrite(MOTOR1A, LOW);
digitalWrite(MOTOR1B, LOW);
digitalWrite(MOTOR2A, LOW);
digitalWrite(MOTOR2B, LOW);
digitalWrite(MOTOR3A, LOW);
digitalWrite(MOTOR3B, LOW);
digitalWrite(MOTOR4A, LOW);
digitalWrite(MOTOR4B, LOW);
digitalWrite(MOTOR5A, LOW);
digitalWrite(MOTOR5B, LOW);
digitalWrite(MOTOR6A, LOW);
digitalWrite(MOTOR6B, LOW);
analogWrite(MOTOR1,0);
analogWrite(MOTOR2,0);
analogWrite(MOTOR3,0);
analogWrite(MOTOR4,0);
analogWrite(MOTOR5,0);
analogWrite(MOTOR6,0);
    }
    
    //x = 0 and y = 1 FRONT
    else {
        //y_direction == 1
        Serial.print("JOYSTICK: FRONT DIRECTION: FRONT");
        Serial.print("  x_direction  ");
        Serial.print(x_direction);
        Serial.print("  y_direction  ");
        Serial.println(y_direction);

SERVO1.write(119);
SERVO2.write(37);
SERVO3.write(18);
SERVO4.write(87);
SERVO5.write(117);
SERVO6.write(55);
digitalWrite(MOTOR1A, HIGH);
digitalWrite(MOTOR1B, LOW);
digitalWrite(MOTOR2A, HIGH);
digitalWrite(MOTOR2B, LOW);
digitalWrite(MOTOR3A, HIGH);
digitalWrite(MOTOR3B, LOW);
digitalWrite(MOTOR4A, HIGH);
digitalWrite(MOTOR4B, LOW);
digitalWrite(MOTOR5A, HIGH);
digitalWrite(MOTOR5B, LOW);
digitalWrite(MOTOR6A, HIGH);
digitalWrite(MOTOR6B, LOW);
analogWrite(MOTOR1,255);
analogWrite(MOTOR2,255);
analogWrite(MOTOR3,255);
analogWrite(MOTOR4,255);
analogWrite(MOTOR5,255);
analogWrite(MOTOR6,255);
    }
  }

  else {//x_direction == 1
  
    //x = 1 and y = -1 BACK RIGHT
    if (y_direction == -1){ 
        Serial.print("JOYSTICK: BACK RIGHT DIRECTION: BACK RIGHT");
        Serial.print("  x_direction  ");
        Serial.print(x_direction);
        Serial.print("  y_direction  ");
        Serial.println(y_direction);

SERVO1.write(90);
SERVO2.write(10);
SERVO3.write(50);
SERVO4.write(85);
SERVO5.write(155);
SERVO6.write(55);
digitalWrite(MOTOR1A, LOW);
digitalWrite(MOTOR1B, HIGH);
digitalWrite(MOTOR2A, LOW);
digitalWrite(MOTOR2B, HIGH);
digitalWrite(MOTOR3A, LOW);
digitalWrite(MOTOR3B, HIGH);
digitalWrite(MOTOR4A, LOW);
digitalWrite(MOTOR4B, HIGH);
digitalWrite(MOTOR5A, LOW);
digitalWrite(MOTOR5B, HIGH);
digitalWrite(MOTOR6A, LOW);
digitalWrite(MOTOR6B, HIGH);
analogWrite(MOTOR1,255);
analogWrite(MOTOR2,127);
analogWrite(MOTOR3,255);
analogWrite(MOTOR4,255);
analogWrite(MOTOR5,127);
analogWrite(MOTOR6,127);
    }
        
    //x = 1 and y = 0 TURN AROUND RIGHT
    else if (y_direction == 0){ 
        Serial.print("JOYSITCK: RIGHT DIRECTION: TURN AROUND RIGHT");
        Serial.print("  x_direction  ");
        Serial.print(x_direction);
        Serial.print("  y_direction  ");
        Serial.println(y_direction);

SERVO1.write(80);
SERVO2.write(85);
SERVO3.write(65);
SERVO4.write(87);
SERVO5.write(80);
SERVO6.write(55);
digitalWrite(MOTOR1A, LOW);
digitalWrite(MOTOR1B, HIGH);
digitalWrite(MOTOR2A, LOW);
digitalWrite(MOTOR2B, HIGH);
digitalWrite(MOTOR3A, HIGH);
digitalWrite(MOTOR3B, LOW);
digitalWrite(MOTOR4A, HIGH);
digitalWrite(MOTOR4B, LOW);
digitalWrite(MOTOR5A, HIGH);
digitalWrite(MOTOR5B, LOW);
digitalWrite(MOTOR6A, LOW);
digitalWrite(MOTOR6B, HIGH);
analogWrite(MOTOR1,255);
analogWrite(MOTOR2,255);
analogWrite(MOTOR3,255);
analogWrite(MOTOR4,255);
analogWrite(MOTOR5,255);
analogWrite(MOTOR6,255);
delay(100);
digitalWrite(MOTOR1A, HIGH);
digitalWrite(MOTOR1B, LOW);
digitalWrite(MOTOR2A, LOW);
digitalWrite(MOTOR2B, HIGH);
digitalWrite(MOTOR3A, HIGH);
digitalWrite(MOTOR3B, LOW);
digitalWrite(MOTOR4A, HIGH);
digitalWrite(MOTOR4B, LOW);
digitalWrite(MOTOR5A, LOW);
digitalWrite(MOTOR5B, HIGH);
digitalWrite(MOTOR6A, LOW);
digitalWrite(MOTOR6B, HIGH);
analogWrite(MOTOR1,100);
analogWrite(MOTOR2,100);
analogWrite(MOTOR3,100);
analogWrite(MOTOR4,100);
analogWrite(MOTOR5,100);
analogWrite(MOTOR6,100);
    }

    //x = 1 and y = 1 FRONT RIGHT
    else { 
        //y_direction == 1
        Serial.print("JOYSTICK: FRONT RIGHT DIRECTION: FRONT RIGHT"); 
        Serial.print("  x_direction  ");
        Serial.print(x_direction);
        Serial.print("  y_direction  ");
        Serial.println(y_direction);

SERVO1.write(90);
SERVO2.write(10);
SERVO3.write(50);
SERVO4.write(85);
SERVO5.write(155);
SERVO6.write(55);
digitalWrite(MOTOR1A, HIGH);
digitalWrite(MOTOR1B, LOW);
digitalWrite(MOTOR2A, HIGH);
digitalWrite(MOTOR2B, LOW);
digitalWrite(MOTOR3A, HIGH);
digitalWrite(MOTOR3B, LOW);
digitalWrite(MOTOR4A, HIGH);
digitalWrite(MOTOR4B, LOW);
digitalWrite(MOTOR5A, HIGH);
digitalWrite(MOTOR5B, LOW);
digitalWrite(MOTOR6A, HIGH);
digitalWrite(MOTOR6B, LOW);
analogWrite(MOTOR1,255);
analogWrite(MOTOR2,127);
analogWrite(MOTOR3,255);
analogWrite(MOTOR4,255);
analogWrite(MOTOR5,127);
analogWrite(MOTOR6,127);
        }
  }
}

BLYNK_WRITE(V1) //RIGHT
{
  int pinValue = param.asInt(); // assigning incoming value from pin V1 to a variable
  Serial.print("RIGHT: ");
  Serial.println(pinValue);
  if(pinValue == 1) {
    
SERVO1.write(32);
SERVO2.write(127);
SERVO3.write(105);
SERVO4.write(0);
SERVO5.write(27);
SERVO6.write(145);
digitalWrite(MOTOR1A, LOW);
digitalWrite(MOTOR1B, HIGH);
digitalWrite(MOTOR2A, LOW);
digitalWrite(MOTOR2B, HIGH);
digitalWrite(MOTOR3A, HIGH);
digitalWrite(MOTOR3B, LOW);
digitalWrite(MOTOR4A, LOW);
digitalWrite(MOTOR4B, HIGH);
digitalWrite(MOTOR5A, HIGH);
digitalWrite(MOTOR5B, LOW);
digitalWrite(MOTOR6A, LOW);
digitalWrite(MOTOR6B, HIGH);
analogWrite(MOTOR1,255);
analogWrite(MOTOR2,255);
analogWrite(MOTOR3,255);
analogWrite(MOTOR4,255);
analogWrite(MOTOR5,255);
analogWrite(MOTOR6,255);
delay(500);
digitalWrite(MOTOR1A, LOW);
digitalWrite(MOTOR1B, HIGH);
digitalWrite(MOTOR2A, HIGH);
digitalWrite(MOTOR2B, LOW);
digitalWrite(MOTOR3A, HIGH);
digitalWrite(MOTOR3B, LOW);
digitalWrite(MOTOR4A, LOW);
digitalWrite(MOTOR4B, HIGH);
digitalWrite(MOTOR5A, LOW);
digitalWrite(MOTOR5B, HIGH);
digitalWrite(MOTOR6A, HIGH);
digitalWrite(MOTOR6B, LOW);
analogWrite(MOTOR1,128);
analogWrite(MOTOR2,128);
analogWrite(MOTOR3,128);
analogWrite(MOTOR4,128);
analogWrite(MOTOR5,128);
analogWrite(MOTOR6,128);
  }
    
  if(pinValue == 0) {

//STOP    
SERVO1.write(119);
SERVO2.write(37);
SERVO3.write(18);
SERVO4.write(87);
SERVO5.write(117);
SERVO6.write(55);
digitalWrite(MOTOR1A, HIGH);
digitalWrite(MOTOR1B, LOW);
digitalWrite(MOTOR2A, HIGH);
digitalWrite(MOTOR2B, LOW);
digitalWrite(MOTOR3A, LOW);
digitalWrite(MOTOR3B, HIGH);
digitalWrite(MOTOR4A, HIGH);
digitalWrite(MOTOR4B, LOW);
digitalWrite(MOTOR5A, LOW);
digitalWrite(MOTOR5B, HIGH);
digitalWrite(MOTOR6A, LOW);
digitalWrite(MOTOR6B, HIGH);
analogWrite(MOTOR1,255);
analogWrite(MOTOR2,255);
analogWrite(MOTOR3,255);
analogWrite(MOTOR4,255);
analogWrite(MOTOR5,255);
analogWrite(MOTOR6,255);
delay(300);
digitalWrite(MOTOR1A, LOW);
digitalWrite(MOTOR1B, LOW);
digitalWrite(MOTOR2A, LOW);
digitalWrite(MOTOR2B, LOW);
digitalWrite(MOTOR3A, LOW);
digitalWrite(MOTOR3B, LOW);
digitalWrite(MOTOR4A, LOW);
digitalWrite(MOTOR4B, LOW);
digitalWrite(MOTOR5A, LOW);
digitalWrite(MOTOR5B, LOW);
digitalWrite(MOTOR6A, LOW);
digitalWrite(MOTOR6B, LOW);
analogWrite(MOTOR1,0);
analogWrite(MOTOR2,0);
analogWrite(MOTOR3,0);
analogWrite(MOTOR4,0);
analogWrite(MOTOR5,0);
analogWrite(MOTOR6,0);
  }
}

BLYNK_WRITE(V2) //LEFT
{
  int pinValue = param.asInt(); // assigning incoming value from pin V2 to a variable
  Serial.print("LEFT: ");
  Serial.println(pinValue);
  if(pinValue == 1) {

SERVO1.write(32);
SERVO2.write(127);
SERVO3.write(105);
SERVO4.write(0);
SERVO5.write(27);
SERVO6.write(145);
digitalWrite(MOTOR1A, LOW);
digitalWrite(MOTOR1B, HIGH);
digitalWrite(MOTOR2A, LOW);
digitalWrite(MOTOR2B, HIGH);
digitalWrite(MOTOR3A, HIGH);
digitalWrite(MOTOR3B, LOW);
digitalWrite(MOTOR4A, LOW);
digitalWrite(MOTOR4B, HIGH);
digitalWrite(MOTOR5A, HIGH);
digitalWrite(MOTOR5B, LOW);
digitalWrite(MOTOR6A, LOW);
digitalWrite(MOTOR6B, HIGH);
analogWrite(MOTOR1,255);
analogWrite(MOTOR2,255);
analogWrite(MOTOR3,255);
analogWrite(MOTOR4,255);
analogWrite(MOTOR5,255);
analogWrite(MOTOR6,255);
delay(500);
digitalWrite(MOTOR1A, HIGH);
digitalWrite(MOTOR1B, LOW);
digitalWrite(MOTOR2A, LOW);
digitalWrite(MOTOR2B, HIGH);
digitalWrite(MOTOR3A, LOW);
digitalWrite(MOTOR3B, HIGH);
digitalWrite(MOTOR4A, HIGH);
digitalWrite(MOTOR4B, LOW);
digitalWrite(MOTOR5A, HIGH);
digitalWrite(MOTOR5B, LOW);
digitalWrite(MOTOR6A, LOW);
digitalWrite(MOTOR6B, HIGH);
analogWrite(MOTOR1,128);
analogWrite(MOTOR2,128);
analogWrite(MOTOR3,128);
analogWrite(MOTOR4,128);
analogWrite(MOTOR5,128);
analogWrite(MOTOR6,128);
  }
    
  if(pinValue == 0) {

//STOP    
SERVO1.write(119);
SERVO2.write(37);
SERVO3.write(18);
SERVO4.write(87);
SERVO5.write(117);
SERVO6.write(55);
digitalWrite(MOTOR1A, HIGH);
digitalWrite(MOTOR1B, LOW);
digitalWrite(MOTOR2A, HIGH);
digitalWrite(MOTOR2B, LOW);
digitalWrite(MOTOR3A, LOW);
digitalWrite(MOTOR3B, HIGH);
digitalWrite(MOTOR4A, HIGH);
digitalWrite(MOTOR4B, LOW);
digitalWrite(MOTOR5A, LOW);
digitalWrite(MOTOR5B, HIGH);
digitalWrite(MOTOR6A, LOW);
digitalWrite(MOTOR6B, HIGH);
analogWrite(MOTOR1,255);
analogWrite(MOTOR2,255);
analogWrite(MOTOR3,255);
analogWrite(MOTOR4,255);
analogWrite(MOTOR5,255);
analogWrite(MOTOR6,255);
delay(300);
digitalWrite(MOTOR1A, LOW);
digitalWrite(MOTOR1B, LOW);
digitalWrite(MOTOR2A, LOW);
digitalWrite(MOTOR2B, LOW);
digitalWrite(MOTOR3A, LOW);
digitalWrite(MOTOR3B, LOW);
digitalWrite(MOTOR4A, LOW);
digitalWrite(MOTOR4B, LOW);
digitalWrite(MOTOR5A, LOW);
digitalWrite(MOTOR5B, LOW);
digitalWrite(MOTOR6A, LOW);
digitalWrite(MOTOR6B, LOW);
analogWrite(MOTOR1,0);
analogWrite(MOTOR2,0);
analogWrite(MOTOR3,0);
analogWrite(MOTOR4,0);
analogWrite(MOTOR5,0);
analogWrite(MOTOR6,0);
  }
}

That’s work, i can connected with my BLE. Next, why i can’t controlled with joyctick and push button? I mean, i use joystick and push button in my sketch. First problem i can’t connected wth BLE (now i’m connected). Second problem after i have connected, i push (on) my push button, but not working, my serial monitor always show

[0] 
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v0.4.10 on Arduino Mega

[5001] Connecting...
[5082] Ready
[10220] Connecting...
[15301] Connecting...
[20382] Connecting...
[25463] Connecting...
[30544] Connecting...
[35625] Connecting...
[40706] Connecting...
[45786] Connecting...
[50866] Connecting...
[55947] Connecting...
[61028] Connecting...
[66109] Connecting...
[71190] Connecting...
[76271] Connecting...
[81352] Connecting...
[86433] Connecting...
[91514] Connecting...
[96595] Connecting...
[101676] Connecting...
[106756] Connecting...
[111836] Connecting...
[116917] Connecting...
[121998] Connecting...
[127079] Connecting...
[132160] Connecting...
[137241] Connecting...
[142322] Connecting...
[147403] Connecting...
[152484] Connecting...
[157565] Connecting...
[162646] Connecting...
[167726] Connecting...
[172806] Connecting...
[177887] Connecting...
[182968] Connecting...
[188049] Connecting...
[193130] Connecting...
[198211] Connecting...
[203292] Connecting...
[208373] Connecting...
[213454] Connecting...
[218535] Connecting...
[223616] Connecting...
[228696] Connecting...
[233776] Connecting...
[238857] Connecting...
[243938] Connecting...
[249019] Connecting...
[249099] Ready
[254141] Connecting...
[259222] Connecting...
[264303] Connecting...
[269384] Connecting...
[274465] Connecting...
[279546] Connecting...
[284627] Connecting...
[289708] Connecting...
[294788] Connecting...
[299868] Connecting...
[304949] Connecting...
[310030] Connecting...
[315111] Connecting...
[320192] Connecting...
[325273] Connecting...
[330354] Connecting...
[335435] Connecting...
[340516] Connecting...
[345597] Connecting...
[350678] Connecting...
[355758] Connecting...
[360838] Connecting...
[365919] Connecting...
[371000] Connecting...
[376081] Connecting...
[381162] Connecting...
[386243] Connecting...
[391324] Connecting...
[396405] Connecting...
[401486] Connecting...
[406567] Connecting...
[411648] Connecting...
[416728] Connecting...
[421808] Connecting...
[426889] Connecting...
[431970] Connecting...
[437051] Connecting...
[442132] Connecting...
[447213] Connecting...
[452294] Connecting...
[457375] Connecting...
[462456] Connecting...
[467537] Connecting...
[472619] Connecting...
[477699] Connecting...
[482779] Connecting...
[487860] Connecting...
[492941] Connecting...
[493022] Ready
[498063] Connecting...
[503144] Connecting...
[508225] Connecting...
[513306] Connecting...
[518387] Connecting...
[518467] Ready (ping: 0ms).
[523469] Connecting...

I read some widget not allowed with BLE, include joystick and push button?

Looks like you still have this command… change it to:

Serial.println("Waiting for connections...");

Upss, sorry, i forgot that. In my sketch i’m upload to my mega, i delete that code… :grinning:

Thank you for correction.

Hello, can someone help me with this always connecting in serial monitor while BLE already connected?

In your serial monitor it says “OK+CONN”, this is wrong.

Have a look at