Example of Locker With Arduino Matrix Keypad 4x4

by manu4371 in Circuits > Arduino

1608 Views, 2 Favorites, 0 Comments

Example of Locker With Arduino Matrix Keypad 4x4

iNTRO2jpg.jpg

2 ways to manage a 16 pushbuttons keypad with a minimum of pins.

Intro

I recently worked on a way to manage a 4x4 touch keypad matrix connected to an Arduino clone. The set points were:

-to use only 4+1 pins instead of 8 pins on the atmega328p

-to add a LCD Display 4x20 CHAR link via I2C (2 pins)

-to control digital and analog outputs.

So, having a lot of things to control with a sin amount of I/O.

Things to Use:

thingstouse.jpg

I bought a LCD display 4x20 characters and an I2C module adaptator to connect the display with SDA (A4) and SCL (A5) pins on my arduino clone.

I use the famous and now obsolete MM74C922N: a 8 to 4 ways converter fit to the 4x4 matrix keypad.

I created a clone of the arduino based on the atmega328p and programmed via an HE10 connector (SPI bus) and an USBasp cable.

Schematic and the Board:

THEBOARD.jpg
KEYPADarduino.jpg

The board is made of:

-the LCD keypad only use with Arduino IDE, not possible with LDmicro (Ladder programming)

-the MM74C922N board: 16 pushbuttons coded on 16 binary values on 4 bits DCBA. When a button is pressed: the blue led lights on and a value appears on DCBA (A is the LSB). When a button is released: the blue led lights off and the value is reset to zero on DCBA.

-the Arduino atmega238p clone board.

Using LDmicro With Ladder Programming:

sfc.jpg
tableCODE.jpg
0STEP.jpg
1STEP.jpg
2STEP.jpg
3STEP.jpg
4STEP.jpg
5STEP.jpg

The code to enter is made of 4 values among 16 keypressed values so 16x16x16x16 combinations.

Once you draw the SFC, you have then to translate it into LADDER with the method given in one of my

instructables :

https://www.instructables.com/id/Arduino-tomation-...

Once typed, compile it as xxxx.hex and then download it with KHAZAMA downloader.

The LCD display cannot be programed on LDmicro.

I give LDmicro zip with the sketch SERRURE.id in it and the KHAZAMA downloader.

Using Arduino IDE 1.8.x With Mightycore and SMlib:

STATEMACHINE.jpg

I translate the SFC into a state machine. Then I used Arduino IDE with the Mightycore and SM library inside.

I display message like: ERROR, WAITING, UNLOCK, state reached, value of the keypressed on the LCD diplay.

I give you the sketch and the SM lib. For Mightycore look at this:

https://www.instructables.com/id/Arduino-18x-Clone...

To Conclude:

These are two ways to manage the 16 keypad and it took me several hours to find the good sequence but now it works fine. You must respect these steps:

-1 detect a keypressed on a rising edge of the DA pin

-2 read the value generated on DCBA and compare to the good one

Unless it will certainly not work.

Thanks to all interesting tutorial over the net.