Breaking

Site moved to https://diyusthad.com

Secret pattern lock using Arduino

Introduction

In this project, we are making a pattern lock using Arduino and Solenoid lock.
The lock will only get opened when the correct pattern is entered. the pattern is a combination of "long" and "short" press of the pattern switch.

Arduino pattern lock
Avoid the relay in the circuit, I have not used them


Watch the video



Things Used

  • Arduino Nano
  • Micro push-button x2
  • TIP120 transistor
  • LEDs x2
  • Resistors x5
  • 1N007 Diode




Theory 

  • The code will constantly monitor the enter switch and patter switch state and store it
  • Whenever I press the pattern button, the time from millis() function will be stored in two variables, one for press time and one for release time.
  • then the time difference between the release and press will be calculated and stored.
  • then using an if condition the program will check whether the time difference is less-than or greater-than the predefined time for "short" and "long" press.
  • then the code will check whether there is any space for the last detected press and if will be stored to the nearly available NULL space in the pattern lock array until all the array is filled
  • now if we press the enter button the program will compare the default pattern and the patter which you just entered.
  • if the pattern is true then the transistor will turn on and all the values stored to the pattern array will be erased.
  • if the pattern is false then the transistor will remain off and all the values stored to the pattern array will be erased.
  • also, I have added some LEDs for indication


Circuit

Connect the Circuit as shown,


Arduino lock circuit

  • Digital pin 2 and 3 to enter and the pattern button.
  • Digital pin 5 and 6 for Red and Green LEDs.
  • Digital pin 12 to the transistor base.
  • Transistor emitter to GND.
  • Transistor collector to Solenoid ground.
  • 12v to Solenoid VCC.
  • Don't forget to connect ground of 12 to ground of Arduino
  • The diode in between VCC and ground of solenoid
  • and don't forget all the resistors.

Code

Secret pattern lock using Arduino Reviewed by Abu Yazid on April 13, 2019 Rating: 5
All Rights Reserved by Site Moved © 2014 - 2019

Contact Form

Name

Email *

Message *

Powered by Blogger.