Muhammad_Munir
Published © GPL3+

Voice Command Door Lock

How to Lock and unlock your door with voice command

IntermediateProtip8,551
Voice Command Door Lock

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Jumper wires (generic)
Jumper wires (generic)
×2
Car door lock actuator
×1
Relay (generic)
×4
BD139 Transistor
×1
2.2k Resistor
×2
HC-05 Bluetooth Module
×1
12 volt Adapter
×1

Software apps and online services

Arduino Voice controller

Hand tools and fabrication machines

Hot glue gun (generic)
Hot glue gun (generic)
Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Schematics

Door Lock

Code

Voice Door lock

Arduino
String voice;

#define lockPin 12
#define unlockPin 11
void setup() 
{                                            // put your setup code here, to run once:
  Serial.begin(9600);
  pinMode(lockPin, OUTPUT);
  pinMode(unlockPin, OUTPUT);
 
}
void loop() {
 
  while (Serial.available())   //Check if there is an available byte to read
  {                            
  delay(10);                   //Delay added to make thing stable
  char c = Serial.read();      //Conduct a serial read
  voice += c;                  //Shorthand for voice = voice + c
  } 

  if (voice.length() > 0) {
    Serial.println(voice);
  if(voice == "door lock")//                             
     {
   
     digitalWrite(lockPin,HIGH);
     delay(3000);
     digitalWrite(lockPin,LOW);
    
     }  
  else if(voice == "door unlock")//                              
     {
    
    digitalWrite(unlockPin,HIGH);
     delay(3000);
     digitalWrite(unlockPin,LOW);
     }
 voice="";                                                       //Reset the variable after initiating
  }}

Credits

Muhammad_Munir

Muhammad_Munir

77 projects • 48 followers
I am Arduino programmer, also expertise in ESP32 and 8266 wifi modules.

Comments