УДК 621.38
Hamzayev A.I. senior lecturer Department of Radio Electronics Jizzakh Polytechnic Institute
READ DATA FROM KEYBOARD AND OUTPUT TO LCD DISPLAY.
CODE LOCK
Abstract. This article discusses the code lock that shows how to read data from the keyboard and output it to the LCD screen, and the connection schemes are explained and analyzed in detail.
Keywords: LCD, HD44780, Arduino, Circuit), String, Genuino, I2C, IIC, LED, USB, SDA, SCL, motherboard, Sketch, digitalWrite.
Theoretical information.
Liquid crystal indicators display symbolic information. They come in different sizes, measured by the number and length of lines displayed. Some are backlit and allow you to choose the color of the characters and background. Any LCD display with a compatible HD44780 interface and a 5V backlight supply voltage can work with the Arduino board [1].
The I2C adapter module allows you to connect the character display to the Arduino board with just two signal wires. I2C is a serial two-wire bus for communicating integrated circuits inside electronic devices, known as I 2 C or IIC (Inter-Integrated Circuit). I2C was developed by Philips in the early 1980s. as a simple 8-bit bus for internal communication between circuits in control electronics, such as computers on motherboards, mobile phones, etc [2]. (Fig. 1.).
Fig. 1. Connecting multiple devices to the I2C bus
интерфейс I2C
vcc -
1.5k
SDA -
SCL -
The LCD display with I2C adapter module connects to the Arduino with only 4 wires - 2 data wires and 2 power wires.
ЕШ
To connect an LCD display to Arduino via an I2C adapter module, you need to install the LiquidCrystal_I2C library. You also need the Wire library, which is already installed in the standard Arduino IDE program [3].
LiquidCrystal_I2C library.
The LiquidCrystal_I2C(address, col, row) constructor creates an object of type LiquidCrystal_I2C and accepts display connection parameters (I2C address and display size) [4].
Functions:
- init() - initialization of the LCD display;
- backlight() - turns on the backlight;
- nobacklight() - turns off the backlight;
- clear() - clears the screen and returns the cursor to the starting position;
- setCursor(x,y) - setting the cursor to a given position;
- print(string) - displays text on the display;
- cursor() - shows the cursor, i.e. the underline under the place of the next character;
- noCursor() - hides the cursor;
- blink() - cursor blinking;
- noBlink() - cancel blinking;
- noDisplay() - turns off the display while saving all displayed information;
- display() - turns on the display and saves all displayed information;
- scrollDisplayLeft() - scrolls the display contents 1 position to the left;
- scrollDisplayRight() - scrolls the display contents 1 position to the right;
- autoscroll() - enable autoscrolling;
- noAutoscroll() - disable autoscrolling;
- leftToRight() - sets the text direction from left to right;
- rightToLeft() - text direction from right to left;
- createChar(index, Letter) - creates a custom character for the display.
Connecting a membrane matrix keyboard to Arduino [5,6].
In projects where the Arduino is not connected to a computer, you need to be able to enter characters, such as a secret code, to turn something on or off. To
do this, use a matrix keyboard (Fig.2).
The advantage of such a keyboard is that only 8 contacts are used instead of 16. For this circuit to work, it is necessary to use dynamic polling of the keyboard. The Arduino pins to which keyboard pins 1, 2, 3 and 4 are connected are configured as digital outputs, and the pins to which 5, 6, 7 and 8 are connected are configured as inputs [7,8]. A low voltage level is alternately applied to pins 1, 2, 3 and 4 of the keyboard. Pins 5, 6, 7 and 8 are under control. If the button is pressed, the Arduino will determine which line the 42nd level was low on and from which line it came to the Arduino input. As a result, the coordinates of the button will be determined [9].
Description of the demo program.
The program simulates the operation of a combination lock. Connected to Arduino:
- 4x4 matrix keyboard, the pins of which are connected to digital pins 2..9 of Arduino;
- 16x2 LCD display, which is connected to Arduino via an I2C adapter board; The riser board is connected to pins A4 (SDA) and A5 (SCL) of the Arduino;
- two LEDs LED1 and LED2, which are connected to pins 10 and 11 of the Arduino, respectively.
After power is applied, the Arduino LED lights up, which is connected incircuit to pin 13. The INSERT CODE message is displayed on the top line of the display, and the cursor blinks on the bottom line. LED1 also lights up, which means the lock is closed [10,11].
After dialing the code 8888, press # to confirm. If the code is entered correctly, the message CORRECT CODE is displayed on the top line of the display and the entered code on the bottom line is deleted. The lock opens for 4 seconds, which means that LED1 goes out and LED2 lights up. After 4 seconds, LED2 goes out and LED1 lights up again. The INSERT CODE message appears again on the top line of the display. If the code is entered incorrectly, INCORRECT CODE appears on the top line of the display. After 2 seconds, the information on the display is cleared and the INSERT CODE message appears again [12]. After the third attempt, a 30-second countdown begins: INCORRECT CODE is displayed on the top line of the display, and WAIT XX SECONDS is displayed on the bottom line, where XX seconds (30, 29, 28, etc.). After 30 seconds have passed, the message INSERT CODE is displayed on the top line of the display and the program again waits for the code to be entered [13,14].
The program is restarted using the Reset button on the Arduino.
The order of work.
1. Launch Arduino IDE.
2. Make sure the LiqudCrystal-I2C library is installed in the Arduino IDE. To do this, in the main menu of the Arduino IDE, select Sketch / Connect library and, if it is not there, install it (section 9.2).
3. Make sure that the Arduino Uno board is selected in the Arduino IDE, for which in the main menu of the Arduino IDE select Tools / Board: "Arduino / Genuino Uno" / Arduino / Genuino Uno [15].
4. Compile the sketch and search for and correct errors if they arise.
5. Connect the Arduino to your computer via a USB cable and flash the program into memory. Disconnect the USB cable from the Arduino.
6. Make the necessary connections on the board in accordance with the diagram shown on the front panel (Fig. 3).
7. Make sure that the program works as described: enter the correct code and monitor the program's actions. Do the same by entering the wrong code [16].
8. Make changes to the sketch in accordance with the given option from the "Additional tasks" section. Before the program code, add a comment containing the text of the completed individual task [17].
9. Flash the program into the Arduino memory and make sure that the program works as required by the job.
10. Save the sketch and close it.
Fig. 3. Connection diagram
USB
ALPHABETICAL NUMERIC LCD DISPLAY
A—1 4 C
I2C MODULE
Here is an example of a code lock program that reads data from the keyboard and outputs it to an LCD display using Arduino programming language:
References:
1. Mustofoqulov, J. A., & Bobonov, D. T. L. (2021). "MAPLE" DA SO'NUVCHI ELEKTROMAGNIT TEBRANISHLARNING MATEMATIK TAHLILI. Academic research in educational sciences, 2(10), 374-379.
2. Mustofoqulov, J. A., Hamzaev, A. I., & Suyarova, M. X. (2021). RLC ZANJIRINING MATEMATIK MODELI VA UNI "MULTISIM" DA HISOBLASH. Academic research in educational sciences, 2(11), 1615-1621.
e
3. Иняминов, Ю. А., Хамзаев, А. И. У., & Абдиев, Х. Э. У. (2021). Передающее устройство асинхронно-циклической системы. Scientific progress, 2(6), 204-207.
4. Каршибоев, Ш. А., Муртазин, Э. Р., & Файзуллаев, М. (2023). ИСПОЛЬЗОВАНИЕ СОЛНЕЧНОЙ ЭНЕРГИИ. Экономика и социум, (4-1 (107)), 678-681.
5. Мулданов, Ф. Р., Умаров, Б. К. У., & Бобонов, Д. Т. (2022). РАЗРАБОТКА КРИТЕРИЙ, АЛГОРИТМА И ЕГО ПРОГРАММНОГО ОБЕСПЕЧЕНИЯ ДЛЯ СИСТЕМЫ ИДЕНТИФИКАЦИИ ЛИЦА ЧЕЛОВЕКА. Universum: технические науки, (11-3 (104)), 13-16.
6. Мулданов, Ф. Р., & Иняминов, Й. О. (2023). МАТЕМАТИЧЕСКОЕ, АЛГОРИТМИЧЕСКОЕ И ПРОГРАММНОЕ ОБЕСПЕЧЕНИЕ СОЗДАНИЯ СИСТЕМЫ РОБОТА-АНАЛИЗАТОРА В ВИДЕОТЕХНОЛОГИЯХ. Экономика и социум, (3-2 (106)), 793-798.
7. Ирисбоев, Ф. Б., Эшонкулов, А. А. У., & Исломов, М. Х. У. (2022). ПОКАЗАТЕЛИ МНОГОКАСКАДНЫХ УСИЛИТЕЛЕЙ. Universum: технические науки, (11-3 (104)), 5-8.
8. Zhabbor, M., Matluba, S., & Farrukh, Y. (2022). STAGES OF DESIGNING A TWO-CASCADE AMPLIFIER CIRCUIT IN THE "MULTISIM" PROGRAMM. Universum: технические науки, (11-8 (104)), 43-47.
9. Каршибоев, Ш., & Муртазин, Э. Р. (2022). ТИПЫ РАДИО АНТЕНН. Universum: технические науки, (11-3 (104)), 9-12.
10. Омонов С.Р., & Ирисбоев Ф.М. (2023). АВТОМАТИЗИРОВАННЫЕ СИСТЕМЫ ДЛЯ ИСПЫТАНИЙ НА ЭМС НА ОСНОВЕ ПРОГРАММНОЙ ПЛАТФОРМЫ R&S ELEKTRA. Экономика и социум, (5-1 (108)), 670-677.
11. Саттаров Сергей Абудиевич, & Омонов Сардор Рахмонкул Угли (2022). ИЗМЕРЕНИЯ ШУМОПОДОБНЫХ СИГНАЛОВ С ПОМОЩЬЮ АНАЛИЗАТОРА СПЕКТРА FPC1500. Universum: технические науки, (11-3 (104)), 17-20.
12. Якименко, И. В., Каршибоев, Ш. А., & Муртазин, Э. Р. (2023). Джизакский политехнический институт СПЕЦИАЛИЗИРОВАННОЕ МАШИННОЕ ОБУЧЕНИЕ ДЛЯ РАДИОЧАСТОТ. Экономика и социум, 1196.
13. Абдиев, Х., Умаров, Б., & Тоштемиров, Д. (2021). Структура и принципы солнечных коллекторов. In НАУКА И СОВРЕМЕННОЕ ОБЩЕСТВО: АКТУАЛЬНЫЕ ВОПРОСЫ, ДОСТИЖЕНИЯ И ИННОВАЦИИ (pp. 9-13).
14. Раббимов, Э. А., & Иняминов, Ю. О. (2022). ВЛИЯНИЕ ОКИСНОЙ ПЛЕНКИ НА КОЭФФИЦИЕНТЫ РАСПЫЛЕНИЯ КРЕМНИЯ. Universum: технические науки, (11-6 (104)), 25-27.
15. Mustafaqulov, A. A., Sattarov, S. A., & Adilov, N. H. (2002). Structure and properties of crystals of the quartz which has been growth up on neutron irradiated seeds. In Abstracts of 2. Eurasian Conference on Nuclear Science and its Application.
16. Раббимов, Э. А., Жураева, Н. М., & Ахмаджонова, У. Т. (2020). Влияние окисной пленки на коэффициенты распыления кремния. Экономика и социум, (6-2 (73)), 187-189.
17. Yuldashev, F. (2023). HARORATI MOBIL ELEKTRON QURILMALAR ASOSIDA NAZORAT QILINADIGAN QUYOSh QOZONI. Interpretation and researches, 7(1).