Tuesday, 23 April 2013 12:17

Password access with Arduino using keypad

Written by
Arduino and Keypad
This example demonstrates how to use a 4x4 matrix keypad access password from an Arduino. Sketch below required to install password and keypad library, both available at Arduino Playground. Below list the functions of password library:

Set the target password equal to password.

Is the target password equal to password

Append a character to the currently guessed password

Reset the currently guessed password

Is the guessed password equal to the target password?



How it works

  • The secret password is initialize to 1234, you can change this latter by using password.set() command 
  • The maximum of password length is set to 6, any password input length exceed 6 characters will force to execute checkPassword 
  • Waiting for input, valid key for password is 0 to 9.
  • checkPassword is executed if user press #, it compare input password (guess password) and secret password using password.evaluate()
  • If user press the D key, the secret password will reset to 123. Of course you should use your codes to change secret password with keypad.

Read 33982 times Last modified on Sunday, 12 June 2016 10:59


  • Comment Link Tarciso Ferreira Friday, 07 April 2017 08:15 posted by Tarciso Ferreira

    Tanks, very very nice.

  • Comment Link Bong Tuesday, 07 February 2017 13:25 posted by Bong

    i copied the library into libraries, error found, invalid library foundC:\Users\Bonggicious\Documents\Arduino\libraries\Password

  • Comment Link admin Monday, 25 April 2016 11:10 posted by admin

    I have an electronic code lock project which is written in Chinese. On the top left of the webpage, there is a combox use to translate the article to other languages.


  • Comment Link Shiva Monday, 25 April 2016 06:33 posted by Shiva

    Good tutorial, just one doubt that i have,
    How to ask user to enter old password, verify and change password inside changePassword() function.??

  • Comment Link admin Sunday, 06 March 2016 13:14 posted by admin

    1. use your keyboard to change the password and store it in EEPROM
    2. Read the password from EEPROM on startup
    3. Use password.set(EEPROM_password) to initialize your password

  • Comment Link don sim Saturday, 05 March 2016 23:25 posted by don sim

    How do you reset pass to another # without scanning? Is there a way to set it by the keyboard ie user defined?

Leave a comment

Back to Top