Pages: [1]   Go Down
Author Topic: 4017 IC keyboard matrix controller and library  (Read 4 times)
0 Members and 1 Guest are viewing this topic.
Sydney, Australia
Online Online
Edison Member
Karma: 27
Posts: 1187
Big things come in large packages
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I recently came across these articles describing an implementation of one or more 4017 decade counter ICs used to implement a keyboard matrix.

I thought the idea and approach looked interesting and decided to do a mini-project to test it out.

Diodes isolate the 4017 counter outputs in the event that two or more switches are closed at the same time, allowing simultaneous presses to be detected properly. The number of switches connected can be increased by cascading multiple CD4017 or by using a matrix style arrangement. The nice thing is that at all times the interface to the Arduino remains just 3 pins (Clock, Reset and the digital output from the matrix).  Two counters in a matrix arrangement can be used to monitor up to 100 switches, still just using 3 interface pins.

According to the articles, Reset can be omitted but I decided to leave it in because reliable operation following the initial power-up reset depends on the CD4017 counter’s remaining synchronized with the Arduino counter. This is easiest done by resetting the 4017 at the start of every scan.

I have also implemented a scalable library to read the key matrix using the 4017 IC. The library
- Allows definition of the size of the keyswitch matrix
- Manages the scanning of the 4017 to read the matrix
- Detects the transition from OFF state to ON state for each key
- Implements software debounce and software auto repeat
- Allows detection of multiple simultaneous key presses.

As a proof of concept, and to test the software, I implemented a 3x3 matrix. Attached are JPG images for the circuit, board layout and final product. It works really well and I can see that this keyboard matrix arrangement has the potential to save a lot of I/O pins. Scaling my circuit up top more switches should be straightforward.

The library and all associated documentation, including Eagle CAD files, can be found at my code repository in the signature block below.

* 3x3 Matrix Schematic.JPG (57.32 KB, 919x506 - viewed 1 times.)

* 3x3 Matrix PCB.JPG (53.94 KB, 378x412 - viewed 1 times.)

* 3x3 Matrix Finished Product.jpg (116.55 KB, 530x522 - viewed 1 times.)

Arduino libraries
Parola hardware & library

Pages: [1]   Go Up
Jump to: