STM32 Nucleo board and an AD Keypad

I purchased this module as part of a microcontroller kit, its an interesting little module as it has 16 buttons but with only 1 I/O line is required, an analog input. You connect this to your ST Nucleo and read in the value and display it via the serial port.

The concept is straightforward  you use a resistor network as voltage dividers, and then let each button feed a different voltage to the analog pin. So by detecting the voltage you can tell which button has been pressed. You can only detect one button at a time


Here is the schematic of the module, hopefully you can see what I described earlier


You will have to wire Vcc of the module to 3.3v otherwise the readings will be incorrect, the A0 of the module is connected to A0 (Arduino)



[codesyntax lang=”cpp”]

#include "mbed.h"

Serial pc(USBTX, USBRX);
AnalogIn input(A0);
int main()
 pc.printf("Hello World\n");
 while (1) 

 float reading =*100.0f;
 if (reading < 92.00)
 // print the percentage and 16 bit normalized values
 pc.printf("value: %3.2f%\n",*100.0f);



Pressing the keys from K0 to K16 outputted the following in a serial monitor such as TeraTerm

percentage: 0.00
percentage: 4.52
percentage: 10.70
percentage: 17.02
percentage: 23.25
percentage: 29.26
percentage: 35.41
percentage: 41.95
percentage: 47.94
percentage: 66.08
percentage: 60.51
percentage: 72.14
percentage: 78.61
percentage: 84.66
percentage: 90.72

So using a switch case you can use this module in your own examples, best practice would be to have a high and low value and check between the range. For example Key 1 is 4.52 so you could check for a range between 3 and 5


AD Keypad 16 4×4 Accessory board matrix buttons controlled ADC

This div height required for enabling the sticky sidebar
Ad Clicks : Ad Views : Ad Clicks : Ad Views :