Go Down

Topic: TWO ROBOT CONTROLS (Read 646 times) previous topic - next topic

sml_hkk

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);
    }
}


ballscrewbob

Other post/duplicate DELETED
Please do NOT cross post / duplicate as it wastes peoples time and efforts to have more than one post for a single topic.

Continued cross posting could result in a time out from the forum.

Could you take a few moments to Learn How To Use The Forum.
It will help you get the best out of the forum in the future.
Other general help and troubleshooting advice can be found here.
It may not be the answer you were looking for but its the one I am giving based on either experience, educated guess, google (who would have thunk it ! ) or the fact that you gave nothing to go with in the first place so I used my wonky crystal ball.

Go Up