This analog keyboard, equipped with six tactile pushbuttons, allows users to select from a range of voltage levels with unparalleled precision, making it ideal for diverse electrical applications
A
A
Hardware Overview
How does it work?
Analog Key Click is based on the KMR221, a high-quality SPST switch from C&K. These buttons are rated to endure up to 300,000 switching cycles and have very low ON resistance of less than 100 mΩ. The buttons are rubberized and have a pleasant tactile feel when pressed. By pressing a button, the respective connection point becomes redirected to the input of the OPA344, a low-power operational amplifier from Texas Instruments, which is configured to work with the unity gain, forming a buffer for the input of the microcontroller (MCU). This prevents changes of the impedance at the MCU input pin, as well as a limited amount of ESD protection. By
substituting the voltage divider resistors with two equivalent resistances (RE1 for the upper set of resistors, and RE2 for the lower set of resistors) the principle can be understood even better: when the top button is pressed (T1), the equivalent RE1 resistance will be 0 Ω, so regardless of the RE2 resistance, the voltage at the AN pin will be equal to VCC. When the second button (T2) is pressed, the equivalent RE1 resistance will be 1 kΩ, while the RE2 resistance will be 5K. The VCC voltage for the voltage divider can be selected using the SMD jumper on the Click board™, labeled as VSEL. This jumper selects either a 3.3V or 5V mikroBUS™ power rail as the VCC source. Since there are many
MCUs that cannot tolerate 5V on their pins, the VSEL position is set to 3.3V by default. However, if the 5V operation is required for specific application, it is enough to move the position of the VSEL jumper to the 5V position. The selected output voltage appears at the AN pin of the mikroBUS™, labeled as VO on Analog Key click. It can be then sampled by the A/D converter of the MCU and used to control a device. Since Analog Key click requires just a single pin for its operation, it is perfectly suited for applications where the pin count restriction is a big problem.
Features overview
Development board
Clicker 4 for STM32F3 is a compact development board designed as a complete solution, you can use it to quickly build your own gadgets with unique functionalities. Featuring a STM32F302VCT6, four mikroBUS™ sockets for Click boards™ connectivity, power managment, and more, it represents a perfect solution for the rapid development of many different types of applications. At its core, there is a STM32F302VCT6 MCU, a powerful microcontroller by STMicroelectronics, based on the high-
performance Arm® Cortex®-M4 32-bit processor core operating at up to 168 MHz frequency. It provides sufficient processing power for the most demanding tasks, allowing Clicker 4 to adapt to any specific application requirements. Besides two 1x20 pin headers, four improved mikroBUS™ sockets represent the most distinctive connectivity feature, allowing access to a huge base of Click boards™, growing on a daily basis. Each section of Clicker 4 is clearly marked, offering an intuitive and clean interface. This makes working with the development
board much simpler and thus, faster. The usability of Clicker 4 doesn’t end with its ability to accelerate the prototyping and application development stages: it is designed as a complete solution which can be implemented directly into any project, with no additional hardware modifications required. Four mounting holes [4.2mm/0.165”] at all four corners allow simple installation by using mounting screws. For most applications, a nice stylish casing is all that is needed to turn the Clicker 4 development board into a fully functional, custom design.
Microcontroller Overview
MCU Card / MCU

Architecture
ARM Cortex-M4
MCU Memory (KB)
256
Silicon Vendor
STMicroelectronics
Pin count
100
RAM (Bytes)
40960
Used MCU Pins
mikroBUS™ mapper
Take a closer look
Click board™ Schematic

Step by step
Project assembly
Track your results in real time
Application Output
1. Application Output - In Debug mode, the 'Application Output' window enables real-time data monitoring, offering direct insight into execution results. Ensure proper data display by configuring the environment correctly using the provided tutorial.

2. UART Terminal - Use the UART Terminal to monitor data transmission via a USB to UART converter, allowing direct communication between the Click board™ and your development system. Configure the baud rate and other serial settings according to your project's requirements to ensure proper functionality. For step-by-step setup instructions, refer to the provided tutorial.

3. Plot Output - The Plot feature offers a powerful way to visualize real-time sensor data, enabling trend analysis, debugging, and comparison of multiple data points. To set it up correctly, follow the provided tutorial, which includes a step-by-step example of using the Plot feature to display Click board™ readings. To use the Plot feature in your code, use the function: plot(*insert_graph_name*, variable_name);. This is a general format, and it is up to the user to replace 'insert_graph_name' with the actual graph name and 'variable_name' with the parameter to be displayed.

Software Support
Library Description
This library contains API for Analog Key Click driver.
Key functions:
analogkey_get_key
- This function returns which button is pressed.analogkey_set_resolution
- This function sets the resolution.
Open Source
Code example
The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.
/*!
* \file
* \brief AnalogKey Click example
*
* # Description
* This application logs what button is pressed.
*
* The demo application is composed of two sections :
*
* ## Application Init
* Initializes driver.
*
* ## Application Task
* Reads ADC value and detects which button is pressed based on that value.
*
*
* \author Nemanja Medakovic
*
*/
// ------------------------------------------------------------------- INCLUDES
#include "board.h"
#include "log.h"
#include "analogkey.h"
#define ANALOGKEY_N_SAMPLES 50
// ------------------------------------------------------------------ VARIABLES
static analogkey_t analogkey;
static log_t logger;
// ------------------------------------------------------ APPLICATION FUNCTIONS
void application_init ( void )
{
log_cfg_t log_cfg;
analogkey_cfg_t cfg;
/**
* Logger initialization.
* Default baud rate: 115200
* Default log level: LOG_LEVEL_DEBUG
* @note If USB_UART_RX and USB_UART_TX
* are defined as HAL_PIN_NC, you will
* need to define them manually for log to work.
* See @b LOG_MAP_USB_UART macro definition for detailed explanation.
*/
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, "---- Application Init... ----" );
analogkey_cfg_setup( &cfg );
ANALOGKEY_MAP_MIKROBUS( cfg, MIKROBUS_1 );
if ( analogkey_init( &analogkey, &cfg ) == ADC_ERROR )
{
log_info( &logger, "---- Application Init Error. ----" );
log_info( &logger, "---- Please, run program again... ----" );
for ( ; ; );
}
log_info( &logger, "---- Application Init Done. ----\n" );
}
void application_task ( void )
{
float an_voltage = 0;
analogkey_key_id_t key;
float an_average = 0;
an_voltage = analogkey_read_voltage( &analogkey );
if ( an_voltage > 0.2 )
{
an_average += an_voltage / ANALOGKEY_N_SAMPLES;
for ( uint8_t cnt = 0; cnt < ANALOGKEY_N_SAMPLES - 1; cnt++ )
{
an_voltage = analogkey_read_voltage( &analogkey );
an_average += an_voltage / ANALOGKEY_N_SAMPLES;
}
}
if ( ( key = analogkey_get_key( &analogkey, an_average ) ) != ANALOGKEY_TOUCH_KEY_NONE )
{
log_printf( &logger, " T%u is pressed.\r\n", (uint16_t)key );
while ( analogkey_read_voltage( &analogkey ) > 0.2 ) {
Delay_ms ( 1 );
}
log_printf( &logger, " T%u is released.\r\n", (uint16_t)key );
Delay_ms ( 10 );
}
}
int main ( void )
{
/* Do not remove this line or clock might not be set correctly. */
#ifdef PREINIT_SUPPORTED
preinit();
#endif
application_init( );
for ( ; ; )
{
application_task( );
}
return 0;
}
// ------------------------------------------------------------------------ END
Additional Support
Resources
Category:Pushbutton/Switches