How to build a Digital Code Lock

12/04/2019

Table of Contents

 

Project overview

 

For this project, we will build a simple digital code lock that users can enter and key in. In this tutorial, we will show users how a digital code lock system works in an Arduino Interface.

 

By the end of this tutorial you will be able to :

  • Set up a digital code lock with Zio and basic 12 keys keypad
  • Be able to interface with Arduino IDE to program Zio with keypad
  • Create a program that asks users to enter a six-digit password to unlock 
  • Be able to create a new six-digit password

 

Difficulty Level

Zio Youngling

 


Helpful Resources

For simplicity purposes, this tutorial assumes that you have a full understanding and the know-how on configuring Zio development boards. 

 

For this project, we assume you have already configured Zuino M Uno to interface with Arduino IDE. If you haven't done so we have a separate post on our development board guides. Check them out below:

 

Zuino M Uno Qwiic Start Guide

 


Schematics

 

 

Setup & Configuration

 

You will need the following modules to build this project:

  1. Zuino M Uno
  2. Zio Qwiic 0.91” OLED Display
  3. Hex Matrix Keypad (4 x 3)
  4. Qwiic Cables 200mm
  5. Breadboard Cables Jumper wires (Male to Female)
  6. Micro USB Cable

 

Step 1:

 

Daisy chain the modules together as shown on the Schematics diagram above.

 

 


Step 2

 

Connect the Keypad using Male to Female Jumpers, to your Zuino M Uno.

 

Below diagram shows the connector pins for this setup.

 

    

 


Step 3 

 

Download and install the following libraries to your Arduino IDE:

 

 

Code

 

Plug your Uno to a computer. Download and Flash the code below to your Uno using the Arduino IDE.

 

 

Alternatively, you can download the code from our Github page.

 

 

Demo

 

Login Test 

 

To test your project, after uploading the code to your Uno, your display will show the following message:

 

 

Input the six-digit password followed by the “#” key. To find the 6 digit password stored in the program code, open the serial monitor and it will show the password for the lock.

 

 

If you successfully login with the correct password you will see a Welcome screen. 

 

 

 

Change Password Test

 

Once you managed to login, you will be able to change the password to a new one. To change the password, confirm it with “*” key.

 

 

In this example, I changed the password from 123456 to 000000 as shown below on the Serial monitor.

 

 


Failed Login Attempt Test

 

With this demo, we also included the function that, with 3 failed attempts of entering correct password, the device will locked itself.

 

To test it, reset your Uno.

 

Try and enter incorrect password 3 times.

 

You will be locked immediately after 3 failed attempts.

 

 

 

 

Got questions or suggestions? Or just want to greet us? Drop us a comment below!

 

Leave a Comment