Controlling the door lock with a keypad

In the following image, we see a keypad with a lock. This section can be merged along with the last project. This device can be controlled from your Raspberry Pi Zero or your Arduino board:

Controlling the door lock with a keypad

 Code to access using the keypad

You can now either copy the code inside a file called Project_keyboard_Access_Control.ino, or just get the complete code from the folder for this project using the Arduino IDE:

void captura() 
{ 
  tecla = customKeypad.getKey(); 

  if (tecla) 
  { 
    digito = digito + 1; 
    if(tecla==35){tecla=0;digito=0;valorf=0;lcd.setCursor(0,0);lcd.print(valorf);
      lcd.print("          ");}          
    if(tecla==48){tecla=0;} 
    if(tecla==42){tecla=0;digito=0;valor = valorf;} 

   if(digito==1){valorf1 = tecla; valorf=valorf1;lcd.setCursor(0,0);
       lcd.print(valorf);lcd.print("          ");}  
     if(digito==2){valorf2 = tecla+(valorf1*10);valorf=valorf2;lcd.setCursor(0,0);
         lcd.print(valorf);lcd.print("          ");} 
    if(digito==3){valorf3 = tecla+(valorf2*10);valorf=valorf3;lcd.setCursor(0,0);
         lcd.print(valorf);lcd.print("          ");} 
    if(digito==4){valorf4 = tecla+(valorf3*10);valorf=valorf4;lcd.setCursor(0,0);
         lcd.print(valorf);lcd.print("          ");} 
    if(digito==5){valorf5 = tecla+(valorf4*10);valorf=valorf5;lcd.setCursor(0,0);
        lcd.print(valorf);lcd.print("          ");digito=0;} 
  } 

This function checks if the code that was typed is correct:

void loop() 
{ 
  captura(); 
  if (valor == 92828) 
  { 
    digitalWrite(lock,HIGH); 
  } 
  if (valor == 98372) 
  { 
    digitalWrite(lock,LOW); 
  } 
} 
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.139.83.57