Bluetooth Actuation using 2 Arduino Unos

Hello Everybody,

This is my first post here and though I’m new to Arduino, I think I am learning quickly. For my next project, I wish to use one Arduino to control another Arduino over bluetooth. I have 2 Arduino Unos and 2 HC-05 Bluetooth modules. With a fair amount of difficulty, I managed to configure them as master and slave and they are all paired up and everytime I power them, they automatically link up with each other. I am certain of this because their status LED’s blink twice a second and that too at the same time.

Now to the actual problem. I wish to send a keyboard input to the first Arduino and use the master module connected to it to send this input to the slave module connected to the second Arduino. The second Arduino then activates a buzzer based on the received input. I have 2 instances of the Arduino IDE running so that I can view the serial monitors linked to 2 different com ports at the same time (I am using windows 10 btw). The problem is that the input doesn’t seem to be transmitted over to the receiver side and so nothing really happens. Every time I type 1 or 2 in the transmitter serial monitor, I can see that the rx led on the 1st Arduino does light up and the transmitter monitor displays “You Pressed :1” or “You Pressed : 2” but nothing really happens after that. And nothing happens on the serial monitor either. I have tried using both hardware serial and software serial but I can’t seem to figure out why it’s not working. For the record, I tried doing the same thing with an android phone and a receiver Arduino and that worked perfectly.

I have attached the sketches for your perusal. Any help would be greatly appreciated. Thanks in advance.

sketch_BluetoothTransmit.ino (915 Bytes)

sketch_BluetoothReceive.ino.ino (1.07 KB)

varun502: I am certain of this because their status LED's blink twice a second and that too at the same time.

This signals power on, ready to connect.

Hi Nick. Thanks for the reply. I realise my statement was not clear when I said they blink twice a second. They blink twice in very quick succession. This happens every second. So I'm sure they are connected. Besides, I got the program to work. Turns out, I just wrote the wrong read and write function. However, another issue I do have is the " You Pressed :" line gets printed three times every time I type 1 or 2. It prints

You Pressed :1You Pressed: You Pressed:

This is the code I'm using:

void loop () { if (Serial.available()>0) { val = Serial.read(); flag=0; } if (flag==0) { Serial.println("You Pressed :"); Serial.write(val); bluetooth.write(val); } flag=1;

if (bluetooth.available()>0) { Serial.write(bluetooth.read()); }

OK, I was referring to a regular 2Hz flash. It appears that you may have an unusual module and I would be glad of a link or picture. There was a time when they were all the same - fast flash=ready, slow flash=AT mode, and steady=connected.

I’m not au fait with Bluetooth<>Bluetooth but here is the receiver test I use

void loop() {
    while (Serial.available()) 
  {
    delay(3);  
    c = Serial.read();
    readString += c; 
  }// end while

  if (readString.length() >0) 
  {  
    Serial.write(c);  
   readString="";  
  } // end if
}