Arduino Bluetooth door lock access control

Hello world! Today i made a Arduino Bluetooth door lock access APP to Lock & Unlock a electrical door lock using a relay, protected by a password. The app is available open source! Just contact me! get the APP on google PLAY!

Arduino Bluetooth door lock access control

Arduino Bluetooth door lock access control

Just wire it up like the schematic, Upload the Arduino Bluetooth door lock access code and download the APP on GOOGLE PLAY.
Make sure the Bluetooth module is disconnected when uploading the code! Or the arduino will get confused.
Pair devices, then connect device. Fill in the password that you set in the code and Lock or Unlock your door!

Parts list:
Arduino, RobotDyn Uno.
Bluetooth Module HC-06.
KY-019 Relay module.
2 x led1 x green 1 x red
Jumper wires set MM/FF/MF
Android Phone.


Author: Danny van den Brande. BlueCore Tech.
String inputString = "";
String command = "";
String value = "";
String password = "fillyourpassword"; //setpassword here
boolean stringComplete = false; 
int relay = 2; 
int greenLed = 5;  
int redLed = 6;    

void setup(){
  Serial.begin(9600);  // make sure it is the same baudrate as your bluetooth module 
  boolean stringOK = false;
  pinMode(relay, OUTPUT);
  digitalWrite(relay, HIGH);
  pinMode(greenLed, OUTPUT);
  pinMode(redLed, OUTPUT);
  digitalWrite(redLed, HIGH);
void loop(){
  if (stringComplete) {
    int pos = inputString.indexOf('=');
    if (pos > -1) {
        command = inputString.substring(0, pos);
        value = inputString.substring(pos+1, inputString.length()-1);  // extract command up to \n exluded
    if(!password.compareTo(value) && (command == "OPEN")){
           Serial.println(" OPEN"); 
    else if(!password.compareTo(value) && (command == "CLOSE")){
           Serial.println(" CLOSE"); 
    else if(password.compareTo(value)){
           Serial.println(" WRONG");
       inputString = "";
       stringComplete = false;
void serialEvent() {
  while (Serial.available()) {
    char inChar = (char); 
    inputString += inChar;
    if (inChar == '\n' || inChar == '\r') {
      stringComplete = true;
void openDoor(){
   digitalWrite(relay, LOW);
   digitalWrite(redLed, LOW);
   digitalWrite(greenLed, HIGH);
void closeDoor(){
   digitalWrite(relay, HIGH);
   digitalWrite(redLed, HIGH);
   digitalWrite(greenLed, LOW);
Danny van den Brande

Programmer, Game Designer, 3D Designer, Web Designer, Graphic Designer. Jup this website looks crappy.. :) But enjoy the projects! Everything you need is here.

Leave a Reply

Your email address will not be published. Required fields are marked *