Qwiic Keypad Hookup Guide

Pages
Favorited Favorite 0

Arduino Examples

Example 1: Read Button

The code for Example1_ReadButton connects to the Qwiic Keypad and prints out the value over the Serial Monitor. Below is a sample readout from the Serial Monitor using sequential button presses of: 1, 2, 3, 4, 5, 6, 7, 8, 9, *, 0, and #.

Serial Monitor readout for Example 1

Serial Monitor readout for Example 1.

Example 2: Read with Time

The code for Example2_ReadWithTime operates exactly like the Example1_ReadButton, except the time between since the last button press is printed. Below is a sample readout.

Serial Monitor readout for Example 2

Serial Monitor readout for Example 2.

Example 3: Change I2C Address

Caution: Will not work if I2C address jumper is bridged.

The code for Example3_ChangeI2CAddress connects to the Qwiic Keypad using the default I2C address set in the library and then prints out the I2C address and firmware version over the Serial Monitor. The sketch then, takes an input from the Serial Monitor to change the I2C address using a decimal value (DEC). Once the I2C address is changed, it is stored in the EEPROM of the Qwiic Keypad. After, the sketch connects to the keypad using the new I2C address and reads the registers for the firmware version again. The example then prints out those values over the Serial Monitor again. As shown in the sample readout below, the input value must between 8-119 (DEC) of unreserved I2C addresses.

Serial Monitor readout for Example 3

Serial Monitor readout for Example 3.

Example 4: I2C Scanner

The forth example, Example4_I2CScanner, scans for devices on the I2C bus and reports them on the Serial Monitor. This is useful for users who have forgotten the changed I2C address of their boards.

Serial Monitor readout for Example 4

Serial Monitor readout for Example 4.

Example 5: Read with Interrupt Pin

Note: This example is requires soldering. A wire must be soldered to the INT pin and connected to an interrupt pin on your microcontroller. As written, the example assumes you are using a Arduino UNO based board, like our RedBoard. The sketch designates Pin 2 as the interrupt pin.

The code for Example5_InterruptRead operates similar to Example1_ReadButton, except that instead of constantly polling the keypad for button presses in software, it responds to a hardware trigger on the interrupt (INT) pin. For more details on interrupts, check out this tutorial on Processor Interrupts with Arduino .

Serial Monitor readout for Example 5

Serial Monitor readout for Example 5.

Example 6: Key in Code

The last example, Example6_Keycode, is a use case example, in which the user must input the correct key code: 1, 2, 3, 4.

Serial Monitor readout for Example 6

Serial Monitor readout for Example 6.