How do I connect the Arduino Uno and Bluetooth module Hc-05 ZS-040th

When wiring
Vcc - + 5V

I code for LEDs ON / OFF

#include <SoftwareSerial.h>
SoftwareSerial mySerial(0, 1); 
int ledpin=13; 
int Data; 
void setup() 
void loop()
   if (mySerial.available())
  mySerial.println("LED On! ");
else  if (Data=='0')
  mySerial.println("LED Off! ");

I manage to pair ANDROID and HC-05 module

When I enter through the BT Terminal command “1” to turn on the LED ON nothing happens.
When the Arduino IDE to Serial montor I type “1” lights up LED on the Android BT terminal writes “LED On!”.
When I give the command “0” LED off and ANDROID BT terminal prints “LED Off!”

There is no communication between Android and Arduino UNO

I would ask for the help, since I am a beginner and I can not solve the resulting problem.

Thank you in advance Dejan

Why would you completely ignore the HardwareSerial instance, Serial, so you can do software serial on the hardware serial pins?

Why is Data a global variable? You should limit the scope of variables to the smallest possible scope.

You should get your bluetooth device off of the hardware serial pins, so you can use them for debugging.

And, of course, you've said nothing about the app that is sending the data. Is it sending '1' or 1?


SoftwareSerial mySerial(0, 1);

is fatal.

You might find the following background notes useful

This ... is fatal.

Only if one is trying to do Serial on the same pins. OP is not. (But, should be).


Thank you for your answers.

I am a beginner in the Arduino programming.
I made an app for Android that will over bluetooth to turn on and off two LEDs.
Below ANDROID app and Arduino code.



#include <SoftwareSerial.h>

SoftwareSerial mySerial(10, 11); // RX, TX
int LED = 8;
int LED1 = 13;
char character;

void setup()  
  // set the data rate for the SoftwareSerial port
  pinMode(LED, OUTPUT);
  pinMode(LED1, OUTPUT);

void loop() // run over and over
    String Data = "";
    while(mySerial.available()) {
     character =;
     delay (10);
    if (Data == "1") digitalWrite(LED, HIGH);
    if (Data == "0") digitalWrite(LED, LOW);
    if (Data == "3") digitalWrite(LED1, HIGH);
    if (Data == "2") digitalWrite(LED1, LOW);

Now I’m interested in how to connect the HC-05 in the picture and change the part of the code

SoftwareSerial mySerial(10, 11); // RX, TX

When you connect as shown run Android APP i manage to pair the BT module. But there is no communication application does not work

When you connect the device to two pins, and read from two other pins, of course there is no communication. Connect it to the pins you read from.

I know that the code that I put read from the pin10 and pin11.

How to change read from pin0 and pin1

I tried to this way but not works

SoftwareSerial mySerial(0, 1); // RX, TX

Can someone help me i write code for LED lighting and communication according to the scheme in the picture.

Why on earth are you trying to do software serial on the hardware serial pins?

I dont knov have to conect hc-05 to arduino. I faind picture and cood on internet and conect like pictur and not work. I ask have to conect hc-05 to arduino uno .

I dont knov have to conect hc-05 to arduino.

Evidently. You might try reading reply#3 again. The notes in the link also have some pretty pictures of wiring - including a voltage divider on Arduino Tx, which isn't a bad idea..