Here are some 16-key (4x4 matrix) keypad examples

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
BrendanSimon
Posts: 26
Joined: Wed Sep 07, 2016 10:46 am

Here are some 16-key (4x4 matrix) keypad examples

Postby BrendanSimon » Sat Dec 17, 2016 11:53 am

Hi,

I have some examples on github for reading a 16-key (4x4 matrix) keypad.


The first example, `keypad_timer.py` uses a timer callback (interrupt) to do the row scanning and processing.

The second example, `keypad_uasyncio` uses a coroutine (task) to process the keypad and place key press events in a queue -- for a second coroutine (`keypad_watcher`) to consume key press events from the queue.

It uses the `hwconfig` module, which can be found in the `hwapi` directory. I'm not sure if this is a good thing or not. I saw it in the micropython sources (`examples/hwapi`) and got the feeling that was the way things were moving towards, but I'm really now sure about it.

Anyway, I'm sure you can work it out and can modify it to use `pyb` module instead if that is easier. I had to use `pyb` for some modules anyhow, as some tweren't available in the `machine` module (e.g. `Timer`).

Please feel free to provide feedback and suggestions.

It was tested using on an Olimex E407 board and a 16-key (4x4 matrix) membrane keypad.


Cheers, Brendan.


Image

Image

Return to “General Discussion and Questions”

Who is online

Users browsing this forum: No registered users and 7 guests