I am using an arduino uno with an HC-05 Bluetooth module to control 2 DC motors. The motor driver I’m using is the Adafruit tb6612. When I try to connect with a Samsung Galaxy (I’ve tried on multiple versions), it says I’ve paired to the HC-05 but the Blynk app still says “Device wasn’t online yet.” I’m relatively new to programming, but if I’m understanding all the examples and forums on here correctly, this code should get input from two different joysticks to control two different motors independently. Is there anything I need to include in my code to make sure the app can connect to the device? Or am I dealing with a hardware issue?
#define BLYNK_PRINT Serial
#define A_IN1 8
#define A_IN2 9
#define B_IN1 12
#define B_IN2 13
#define PWMA 5
#define PWMB 6
#include <SoftwareSerial.h>
SoftwareSerial SwSerial(10, 11); // RX, TX
#include <BlynkSimpleSerialBLE.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "40JmYy0s4MgMhf45nQ0y4_s_07OKzi1G";
SoftwareSerial SerialBLE(10, 11); // RX, TX
void setup()
{
// Debug console
Serial.begin(9600);
SerialBLE.begin(9600);
Blynk.begin(SerialBLE, auth);
Serial.println("Waiting for connections...");
pinMode(A_IN1, OUTPUT);
pinMode(A_IN2, OUTPUT);
pinMode(B_IN1, OUTPUT);
pinMode(B_IN2, OUTPUT);
// pinMode(Standby, OUTPUT);
}
// left motor
BLYNK_WRITE(V1) {
// setup variables for joystick
int x = param[0].asInt();
int y = param[1].asInt();
// move forward if joystick pushed up
if (y > 128) {
digitalWrite(A_IN1, HIGH);
digitalWrite(A_IN2, LOW);
analogWrite(PWMA, y);
}
// move backward if joystick pushed down
else if (y < 128) {
digitalWrite(A_IN1, LOW);
digitalWrite(A_IN2, HIGH);
analogWrite(PWMA, y);
}
// stop if no joystick input
else
digitalWrite(A_IN1, LOW);
digitalWrite(A_IN2, LOW);
}
// right motor
BLYNK_WRITE(V2) {
// setup variables for joystick
int x = param[0].asInt();
int y = param[1].asInt();
// move forward if joystick pushed up
if (y > 128) {
digitalWrite(B_IN1, HIGH);
digitalWrite(B_IN2, LOW);
analogWrite(PWMB, y);
}
// move backward if joystick pushed down
else if (y < 128) {
digitalWrite(B_IN1, LOW);
digitalWrite(B_IN2, HIGH);
analogWrite(PWMB, y);
}
// stop if no joystick input
else
digitalWrite(B_IN1, LOW);
digitalWrite(B_IN2, LOW);
}
void loop()
{
Blynk.run();
}