Categories
TUTORIALS

Using a 4×4 Matrix Keypad to Input Gender and Age

Overview

This tutorial aims to provide a step-by-step instruction to use a keypad with an Arduino Uno to input and interpret gender and sex. It utilizes a 4×4 matrix keypad and builds on Krishna Pattabiraman’s introductory code on CircuitBasics “HOW TO SET UP A KEYPAD ON AN ARDUINO” tutorial, as well as the CustomKeypad example code from the Mark Stanley and Alexander Brevig Keypad Library.

This tutorial’s code groups individuals based on their sex and age to group them in particular age/sex brackets. This code is intended to be later combined with an oximeter for certain health levels to be determined based on heart rate, age, and sex.

Parts

  1. 4×4 Matrix Keypad
  2. Arduino Uno
  3. 8 x Male-to-male wires
  4. USB Cable

Diagram

The following diagram is borrowed from CircuitBasics (the keypad icon cannot be found on Fritzing).
What the wiring should look like in person.

Before running the code, make sure the keypad is wired to the Arduino Uno like above. The connections are fairly simple, with corresponding pins inputted into the keypad being aligned right to left into 2, 3, 4, 5, 6, 7, 8, and 9 digital pin inputs on the Arduino Uno.

Steps

  1. Wire the keypad to the Arduino Uno as shown in the diagram and as described. Plug the Arduino Uno into the computer with Arduino IDE open.
  2. Install the keypad library necessary. Specifically, the library used for this tutorial and for this matrix keypad is Keypad library by Mark Stanley and Alexander Brevig. This library simplifies the setting up of the pins and polling the different columns and rows. To install the Keypad library, go to Sketch > Include Library > Manage Libraries and search for “keypad” and “Mark Stanley”. There is only one version available to install (3.1.0).
  3. Validate and upload the following code on Arduino IDE.

4. Test out the code by entering sex and age into the keypad.

Video Example

Leave a Reply

Your email address will not be published. Required fields are marked *