How do I get my both HC-05 to send data to each other after being connected?

SITUATION
I connected one of the Bluetooth Module to the other, as a Master and Slave, but when I try doing the project from this website:

its not working. I used the same exact code from the website.

PROBLEM:

  • The servo isn't turning
  • The LED isn't blinking
  • I don't see any changes in the Serial Monitor, it stays the same when the potentiometer is turned or when the button is pressed

Please attach the code here. I rather spend time reading code and thinking then poking around on Internet.

First thought. Start using some example code just verifying that any simple data can be exchanged. Have You verified that?

Railroader:
Please attach the code here. I rather spend time reading code and thinking then poking around on Internet.

First thought. Start using some example code just verifying that any simple data can be exchanged. Have You verified that?

No I haven’t yet. I will do.

Railroader:
Please attach the code here. I rather spend time reading code and thinking then poking around on Internet.

First thought. Start using some example code just verifying that any simple data can be exchanged. Have You verified that?

This is the codes:

MASTER:

#define ledPin 9
int state = 0;
int potValue = 0;

void setup() {
pinMode(ledPin, OUTPUT);
digitalWrite(ledPin, LOW);
Serial.begin(38400); // Default communication rate of the Bluetooth module
}

void loop() {
if(Serial.available() > 0){ // Checks whether data is comming from the serial port
state = Serial.read(); // Reads the data from the serial port
}

// Controlling the LED
if (state == ‘1’) {
digitalWrite(ledPin, HIGH); // LED ON
state = 0;
}

else if (state == ‘0’) {
digitalWrite(ledPin, LOW); // LED ON
state = 0;
}

// Reading the potentiometer
potValue = analogRead(A0);
int potValueMapped = map(potValue, 0, 1023, 0, 255);
Serial.write(potValueMapped); // Sends potValue to servo motor
delay(10);
}

SLAVE:

#include <Servo.h>
#define button 8
Servo myServo;
int state = 20;
int buttonState = 0;

void setup() {
pinMode(button, INPUT);
myServo.attach(9);
Serial.begin(38400); // Default communication rate of the Bluetooth module
}

void loop() {
if(Serial.available() > 0){ // Checks whether data is comming from the serial port
state = Serial.read(); // Reads the data from the serial port
}

// Controlling the servo motor
myServo.write(state);
delay(10);

// Reading the button
buttonState = digitalRead(button);
if (buttonState == HIGH) {
Serial.write(‘1’); // Sends ‘1’ to the master to turn on LED
}

else {
Serial.write(‘0’);
}
}

Railroader:
Please attach the code here. I rather spend time reading code and thinking then poking around on Internet.

First thought. Start using some example code just verifying that any simple data can be exchanged. Have You verified that?

How do I verify it ?

I'm sorry. I was a bit too short in my advice.
Use IDE and autoformat. Then copy that code into Forum using code tags. That symbol is found up to the left in this window. Things like misplaced, or missing, curly brackets show up quickly.
Some helpers use smartphones or tablets and don't have a full Pc screen.

Every sysem should be verified step by step. No knowing, professional, system buildr would ever smash all components in from the beginning and then starting the tests.
Verify one part at the time.

Start trying some example code for Bluetooth communicatiomn. Disregard all other stuff. Wireless communication is difficult to test. Use test prints via Serial Monitor, to tell what is sent, and what is received.