How to use bluetooth module using arduino


Materials:-
Diagram:-


Connections:-

Bluetooth module(HC-06) to arduino
  •  VCC = Arduino 5v
  •  GND = Arduino GND
  •  RX pin = Arduino TX (1)
  •  TX pin = Arduino RX (0)
LED to arduino

  • LED ( - )  = Arduino GND
  • LED ( + ) = Arduino digital pin13  

YOU MUST REMOVE RX,TX PIN BEFORE UPLOADING CODE

Code:-

char val;

void setup() {
  pinMode(13, OUTPUT);
  Serial.begin(9600);

}

void loop() {
  if (Serial.available()) {
    val = Serial.read();
    Serial.println();
  }
  if (val == '1')
  { digitalWrite(13, HIGH);

  }
  else 
  if (val == '2')
  {
    digitalWrite(13, LOW);
  }

  delay(100);
}