I want to control two robots at the same time but I couldn't write the codes, can you help?
I have two HC-05 modules with Master-Slave connection and another HC-06.
There is not a problem with Bluetooth connections, it is connecting to each other.
I used Arduino nano.
I am just waiting for your help in writing master-slave codes.
The single run codes are as I wrote below.
#include <SoftwareSerial.h>
SoftwareSerial mySerial(11,12); //Tx,Rx
const int in1 = 9;
const int in2 = 8;
const int in3 = 7;
const int in4 = 6;
const int e1 = 10;
const int e2 = 5;
int data;
void setup() {
Serial.begin(9600);
mySerial.begin(9600);
pinMode(in1, OUTPUT);
pinMode(in2, OUTPUT);
pinMode(in3, OUTPUT);
pinMode(in4, OUTPUT);
pinMode(e1, OUTPUT);
pinMode(e2, OUTPUT);
}
void loop()
{
if(mySerial.available())
{
data=mySerial.read();
//Serial.println(data);
}
if(data == 'f')
{
analogWrite(e1,100);
analogWrite(e2,100);
digitalWrite(in1, HIGH);
digitalWrite(in2, LOW);
digitalWrite(in3, HIGH);
digitalWrite(in4, LOW);
}
if(data == 's')
{
digitalWrite(in1, LOW);
digitalWrite(in2, LOW);
digitalWrite(in3, LOW);
digitalWrite(in4, LOW);
}
}