For a major project at school i need to get a bluetooth module to be able to communicate between two HC-05 modules as a master and slave. They need to be able to press a pushbutton on the slave and it lights up a LED on the master. I have been able to get the two hc-05's to connect to each other but i cant find a code and wiring that will work for what i need to do. any help will be appreciated. Thanksmaster code

slave code

  • 1
    When you already have two arduinos and two hc-05 connected to each other, what wireup and code is missing? Commented May 1, 2018 at 12:40
  • The HC-05s are serial bluetooth modules. If you have connected the two HC-05 you already have send them AT commands via your serial interface. What is your problem with sending the needed information over the serial interface?
    – chrisl
    Commented May 1, 2018 at 12:42
  • 1
    please post the code that you have so far .... we can then give you some hints .... please do not expect any ready made solutions, since this is a school assignment
    – jsotola
    Commented May 1, 2018 at 19:14
  • Do not post code as pictures. There is a function in the question editor to properly format code you inserted as text. Please use it
    – chrisl
    Commented May 3, 2018 at 12:43

1 Answer 1


So, you have done the hard part and now need the easy bit :)

Firstly you need a button (failing that touching two wire together will just about do). There are loads of quick tutorials on the web, here is one https://www.arduino.cc/en/Tutorial/Button. They will end up with you having a pin that goes high or low when the button is pressed, you can either poll/loop to detect the press or go posh and use interrupts (leave that for later). When the pin detects the press you need to send some data via your HC05 link to the master, something like 'ON' or 1, who cares so long as the master understands it. And when it disconnects you need to send a off or 0 message (Remember the number 1 and the character '1' are not the same thing, so make sure you know what you are sending).

When the master receives the command it will execute a bit of code that will send a pin high (lets say pin 7). Connected to pin 7 will be the +ve side of a LED, the -ve leg of the led will be connected to a resistor of 200-250 ohms and the other end of the resistor will be connected to ground. Then when pin7 goes high it will light the resistor.


simulate this circuit – Schematic created using CircuitLab

As always you probably will need to break it down to test it, have a little app that toggles pin 7 high for 2 seconds and low for two seconds, etc (just like blink).

There is a phenomenon called 'bouncing' which is where the useless human finger presses a switch and doesn't instantly create a perfect connection and perfect disconnection. This might make the slave send 101010101010101 when you just expect 1, you can either debounce using software or hardware, but only worry about that if you have a good quality switch :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.