Main Content

How to realize a pattern lock algorithm as in your smart phone for ili9341 touch screens and Arduino IDE

Most people are familiar with pattern lock entries from their smart phone, e.g. for unlocking the phone. Such an unlocking algorithm can also be very useful in small embedded projects, e.g. to open doors or to protect parts of a graphical user interface from unauthorized access.

Hardware
I use an AZ-Touch kit for my code, which are small 2.8” touchscreens in a wall-mounted housing. These kits contain an ili9341 touchscreen and a circuit board onto which a microcontroller board can be plugged. The AZ-Touch are available for different platforms e.g. Feather boards or Arduino MKR. The AZ-Touch usually comes as a (partially assembled kit), in which some components still have to be soldered on.

Of course, you can also use a simple Ili9341 display and connect it to the corresponding microcontroller board with jumper wires. The circuit diagram of the AZ-Touch Feather kit can serve as a reference - see appendix.

Additional Libraries
In order to be able to compile the program in the Arduino IDE, some additional libraries are required, which must be loaded beforehand via the library manager:

Adafruit GFX Library
Adafruit ILI9341
Paul Stoffregen XPT2046 Touchscreen Arduino Library
Pattern definition
At the moment the code does not yet support learning mode. However, this can easily be retrofitted if required. The “correct” pattern still has to be defined manually in the current code. An array with a maximum of 15 points is defined for this purpose.”

Link to article