Components Required for Arduino Touch Screen Door Lock
- Arduino Uno
- 2.4” TFT LCD Display Shield
- Solenoid Lock
- Relay Module
- Buzzer
2.4” TFT LCD Display Shield - Introduction
The 2.4” TFT LCD Touch screen is one of the most common RGB color display modules. The LCD has excellent vivid color contrast and comes with a built-in microSD card connection. This TFT display consists of a bright backlight (4 white-LED backlights) and a colorful 240X320 pixels display. It also features individual RGB pixel control giving a much better resolution than the black and white 128×64 displays. We have used this display earlier in our IoT Menu Ordering System and Biometric voting system projects. Before using it with Arduino, let us take a look at the pinout of this 2.4” TFT LCD screen module.
As you can see, 28 pins will perfectly fit into any Arduino Uno / Arduino Mega Board. The TFT display pins are classified into four main parts i.e. Command Pins, Data Pins, SD Card Pins, and Power Pins. A small classification of these pins is given in the table below.
TFT LCD Connections with Arduino
The 2.4” TFT LCD screen is a perfect Arduino Shield. You can directly mount this display on top of the Arduino Uno/Mega and it will perfectly match with the pins as shown in the image given below.
Circuit Diagram for Touch Screen Door Lock System
The complete schematic to build a Smart Door Lock using Arduino is given below. The circuit was drawn using fritzing, since there was no solenoid lock available, I have used a motor to represent it. Both the solenoid lock and this DC motor do not have any polarity and hence can be connected as such.
With a TFT display mounted on Arduino, we only need to connect a relay module and buzzer to Arduino. The Vcc and GND pins of the Relay Module are connected to 5V and GND of Arduino while the Input pin is connected to the 11th pin of Arduino. The positive pin of Buzzer is connected to digital pin 12 of Arduino and the negative pin is connected to the GND pin of Arduino. The entire setup is powered by the 12V Adapter. The onboard 7805 voltage regulator is used to get the regulated 5V to power the Arduino Uno.
3D Printed Casing for Touch Screen Door Lock System
Next, I measured the dimensions of the setup using the scale and also measured the dimensions of the barrel jack and TFT display to design a casing. My design looked something like this once it was done.
Once I finished the design, I exported it as an STL file, sliced it based on printer settings, and finally printed it. The STL file is also available for download from Thingiverse and you can print your casing using it. After printing, I proceeded with assembling the project set up in a permanent enclosure to install it in a facility. With the complete connection was made, I assembled the circuit into my casing and everything was nicely fit as you can see here.
Programming Arduino for Touch Screen Door Lock System
Here we are using SPFD5408 Library that is the modified version of the original Adafruit Library. Complete code is given at the end of the page. Here we are explaining the important sections of the code. There are four sections involved in this code. The first section is creating a UI of a pin lock. The second is detecting the buttons based on the user's touch, the third is checking the user-entered password and the final section is resetting the password.
Testing the Touch Screen Door Lock System
After connecting all the hardware and uploading the code, now it’s time to test the project. We used an external 12V 1A adapter to power the device. By default, it will show the Pin Lock UI on TFT Display. As soon as the correct password is entered, the door lock gets unlocked and then again gets locked after 8 seconds. The default password can be changed by long-pressing the ‘Cancel’ button and then selecting ‘Yes’ on the next screen.