Arduino Leonardo - Electronic Lock

Placed on

This project is just the barebones. It's an 3X4 Matrix Numpad with an 4 rows x 20 characters display and a servo (optional).

Options:

  • Enable Changing the passcode while the pragram is running
  • Enable the servo (only usefull for testing purposes )
  • Enable the serial debug (only for test purposes or nerds :-) )

Further code changes can be found on my github page: https://github.com/Sani7/ArduinoLock

Arduino Leonardo - Electronic Lock - BOM

Arduino Leonardo - clone In stock This one is a home brew leonardo from https://e2cre8.be/ € 9,95 20x4 Characters lcd module blue Out of stock With the I2C module for easy communication with the leonardo € 5,80 4x4 Button keypad In stock 3X4 button keypad works to € 2,80 FEETECH High-Torque Servo FS5115M In stock This servo is from HITEC Servo (optional) € 22,30 I2C LCD interface module In stock I2C LCD interface module € 1,90 Total € 42,75

How does the code work?

  • First we create all our variables (A lot at first but we use them all)
  • Second we initialize all our libraries
    • The keypad library requires us to give the Keymap (Where every key is positioned), how many rows and colloms there are and where the pins are connected to
    • The LCD library requires us to give some stuff too
    • The servo library requires us to create an attribute for our new servo
  • Features:
    • The initialization of the LCD Now to start the program we want to test if the lcd is fully functional by:
      • Enable, disable and reanabel the backlight
      • Showing the start message on the screen
    • The ability to disable backlight after 30 seconds
    • Getting the pressed key
    • Getting the code from user input
    • Check the code if it's correct or not
    • Open or close the lock
    • Read and write the stored code to eeprom memory
    • Getting a new code while the program is running
    • Comparing the to given codes and see if they match
  • Setup:
    • Getting the eeprom code
    • When enabled initialize the servo library to attach to the servo
    • Initialize the lcd
    • When enabled initialize the Serial communication
  • main loop:
    • Getting the key press
    • When you are in the unlocked state and you press * the lock is going to close
    • When you are in the unlocked state and you press # the lock will enter "Change Passcode" state
    • Open the lock when the LockState in true same as Opened (Pretty straigth forward isn't it)
    • Or getting user input to get the code.
Arduino Leonardo - Electronic Lock - Opened Arduino Leonardo - Electronic Lock - Opened
Current Page 1. Introduction 1. Introduction 2. The Schematic 3. The Keypad 4. The LCD module 5. The Servo 6. The code - part 1 - The Keypad 7. The code - part 2 - The LCD 8. The code - part 3 - The code 9. The code - part 4 - More codes 10. The code - part 5 - Setup and Loop 11. The full code Posted by

Comments

Webwinkelkeur Kiyoh Trustpilot Opencircuit