Hi Guys, this my first time using the HC-05 module. I am trying to start off with a simple program that I found on youtube where, on the master node, when I press the push button, the LED on the slave node should turn. I followed the code and circuit connection as the youtube video but my LED on the slave node is not turning on. I have already used the AT command to set as master and slave and bind them.
Any help would be much appreciated, thanks.
This is my code for Master:
#define button 9
#define led 13
void setup() {
pinMode(button, INPUT);
pinMode(led, OUTPUT);
Serial.begin(9600);
}
void loop() {
int bState = digitalRead(button);
if (bState == LOW){
digitalWrite(led,HIGH);
Serial.write('1');
delay(20);
}
else {
digitalWrite(led,LOW);
Serial.write('2');
delay(20);
}
}
Slave Code:
char Incoming_value = 0; //Variable for storing Incoming_value
void setup()
{
Serial.begin(9600); //Sets the data rate in bits per second (baud rate) for serial data transmission
pinMode(7, OUTPUT); //Sets digital pin 7 as output pin
Serial.println("Hello");
}
void loop()
{
if(Serial.available() > 0)
{
Serial.println("I am receiving");
Incoming_value = Serial.read(); //Read the incoming data and store it into variable Incoming_value
Serial.println(Incoming_value);
if(Incoming_value == '1') //Checks whether value of Incoming_value is equal to A
{
digitalWrite(7, HIGH);
}
else if(Incoming_value == '2')
{
digitalWrite(7, LOW);
}
}
}
By the way, this the output I am getting on my slave node.