Description
Follow the Steps IN ORDER
1. The phone or tablet you use must be Android based.
2. Install the necessary power supplies to activate the Hc05 or Hc06 bluetooth module.
3. If all connections are correct, the light on your bluetooth module will turn on and your module will be activated.
4. First, search for the bluetooth module via the phone's own settings. You will come across the name HC05 or HC06.
5. Now pair this bluetooth module with your phone.
6. Open the app that landed on your phone and confirm the bluetooth permission request to establish a connection. You will see Hc05 or Hc06 on the screen that comes up. Choose...
7. After your selection, your application will match your module. (So first you need to pair with the phone and then with the app.)
8. When bluetooth pairing with the phone is achieved - flashing light on the HC-06 -> turns on continuously.
- Flashing light on HC-05 -> flashes at longer intervals
Note: You can customize buttons 1,2 and 3 in the application for features such as horn, headlight, skid etc.
Now test your work by editing your codes and make the necessary adjustments.
#include
SoftwareSerial communication (13, 12);
// Tx and Rx pins are defined
const int IN1 = 5;
const int IN2 = 6;
// L298N left motor control connections are assigned to IN1 pin 5, IN2 to pin 6
const int IN3 = 9;
const int IN4 = 10;
// L298N has been assigned with the right motor control connections IN3 pin 9, IN4 pin 10
String readString;
// Reading of Bluetooth data started
void setup ()
{
pinMode (IN1, OUTPUT);
pinMode (IN2, OUTPUT);
pinMode (IN3, OUTPUT);
pinMode (IN4, OUTPUT);
// IN1, IN2, IN3 and IN4 pins are assigned as OUTPUT pins
iletisim.beg the (9600); // Bluetooth communication started
Serial.beg the (9600); // Serial monitor started
}
void loop ()
{
while (contact.available ())
{
delay (10);
char c = contact.read ();
readString + = c;
}
if (readString.length ()> 0)
{
Serial.println (ReadString);
if (readString == "STOP")
{
analogWrite (IN1, 0);
analogWrite (IN2, 0);
analogWrite (IN3, 0);
analogWrite (IN4, 0);
}
else if (readString == "NEXT")
{
analogWrite (IN1, 0);
analogWrite (IN2, 255);
analogWrite (IN3, 255);
analogWrite (IN4, 0);
}
else if (readString == "BACK")
{
analogWrite (IN1, 255);
analogWrite (IN2, 0);
analogWrite (IN3, 0);
analogWrite (IN4, 255);
}
else if (readString == "LEFT")
// Right wheels forward, Left wheels must return
{
analogWrite (IN1, 255);
analogWrite (IN2, 0);
analogWrite (IN3, 255);
analogWrite (IN4, 0);
}
else if (readString == "SAG")
// Left wheels should go forward, Right wheels should turn back
{
analogWrite (IN1, 0);
analogWrite (IN2, 255);
analogWrite (IN3, 0);
analogWrite (IN4, 255);
}
else if (readString == "SAGASAGI")
// All wheels go backwards. But the left wheels should spin faster
{
analogWrite (IN1, 255);
analogWrite (IN2, 0);
analogWrite (IN3, 0);
analogWrite (IN4, 125);
}
else if (readString == "SOLASAGI") // All wheels go backwards. But the right wheels should spin faster
{
analogWrite (IN1, 125);
analogWrite (IN2, 0);
analogWrite (IN3, 0);
analogWrite (IN4, 255);
}
else if (readString == "UPTACK")
// All wheels go forward. But the left wheels should spin faster
{
analogWrite (IN1, 0);
analogWrite (IN2, 255);
analogWrite (IN3, 125);
analogWrite (IN4, 0);
}
else if (readString == "LEFT")
// All wheels go forward. But the right wheels should spin faster
{
analogWrite (IN1, 0);
analogWrite (IN2, 124);
analogWrite (IN3, 255);
analogWrite (IN4, 0);
}
readString = "";
// It provides continuous control of communication via Bluetooth.
}
}