The mLink 4x4 matrix keypad is a panel mountable serial (I2C/IIC) 16 key tactile keypad. On the rear of the keypad is mounted a mLink module which continuously scans the keypad (with automatic debouncing) for any key presses. If a key is pressed the module stores the key as an 8 bit ASCII value which can then be read out of its serial interface. It is compatible with other mLink or standard I2C modules allowing you to daisy-chain several different types of modules together using only the two I2C pins of your microcontroller.
For Arduino users you can use the mLink library (see below) to control any type of mLink module. Only one single instance of the library is needed to control multiple types of mLink modules resulting in very little resources overhead and therefore making it great for Arduinos with small amounts of memory and pin counts.
For Raspberry Pi users we have a Python module which can be installed via pip or downloaded and installed directly from our forum. Please see the mLink Python forum thread for requirements and download link here: viewtopic.php?f=131&t=3062&p=8592#p8592
Module specifications:
Module code: HCMODU0188 Supply voltage (VDD): 3.3V to 5.5V Operating range (recommended): -5 to 105oC Keypad type: 16 key matrix tactile keypad in 4x4 arrangement Current consumption (idle): 4.5mA Interfaces: I2C, Keypad I2C Interface speed: 400kbits/s (fast mode) I2C default address (HEX): 0h55 Maximum number of modules: 5 with pullups fitted, 112 with pullups removed* Module dimensions (inc headers): 46mm x 14mm x 11mm Keypad dimensions (inc module): 68.5mm x 65mm x 17mm
*Note the maximum number of connected modules will depend on cable lengths and power requirements of each module. Do not exceed 5 mLink modules connected in series with all pullups fitted.
Arduino Example:
Because the modules use an I2C interface this also means multiple modules can be controlled from a single Arduino I2C interface simply by daisy-chaining them together. Note to control multiple mLink modules of the same type requires changing the default I2C address of the additional modules. See mLink Library Quick Start Guide for how to do this.
- #include "mLink.h" // Include the library
- mLink mLink; // Create an instance of the library
- #define I2C_ADD 0x55 // Default I2C address
- void setup()
- {
- Serial.begin(9600);
- mLink.init(); // Initialise the library
- }
- void loop()
- {
- char key = mLink.read(I2C_ADD, KEYPAD_4X4_KEY); // Read the key status
- if(key) // Has a key been pressed ?
- {
- Serial.print("Key: "); // If so then print out the key
- Serial.println(key);
- }
- }
Raspberry Pi Example:
This program requires the mLink Python library module to be installed. Please see the following forum thread for more information on how to install the Python module and requirements:
viewtopic.php?f=131&t=3062
- from mLink import mLink # Import the mLink module
- import time
- ml = mLink.mLink(1) # Create an instance of the module
- I2C_ADD = 0x55 # Default I2C address is 0x55
- while 1:
- key = ml.Keypad_4X4_Read(I2C_ADD) # Read the keypad
- if key != '': # Is it a valid key?
- print(key) # If so then print it out
- time.sleep(0.1)
mLink Arduino library
viewtopic.php?f=58&t=3001
mLink Raspberry Pi Python module
The mLink python module can be installed with the following terminal command:
- pip install hc-mlink
Alternatively the library can be manually installed by downloading it from the forum and unzipping it to your project folder. See the Python module forum thread for more information and download link:
viewtopic.php?f=131&t=3062&p=8592#p8592
Please note that in some cases there may be additional configuration required. If you have issues getting your Raspberry Pi to communicate with the mLink module then please see the Python module forum thread here: viewtopic.php?f=131&t=3062
mLink Library Quick Start Guide For Arduino Users
https://hobbycomponents.com/downloads/m ... _Guide.pdf
mLink Library Reference Guide For The PTC Temperature Sensor Module
https://hobbycomponents.com/downloads/m ... _Guide.pdf
mLink Specifications and Register Map For The PTC Temperature Sensor Modul
https://hobbycomponents.com/downloads/m ... er_Map.pdf
Libraries, example code, and diagrams are provided as an additional free service by Hobby Components and are not sold as part of this product. We do no provide any guarantees or warranties as to their accuracy or fitness for purpose.
Descriptions and diagrams on this page are copyright Hobby Components Ltd and may not be reproduced without permission.