We strongly encourage users to use Package manager for sharing their code on Libstock website, because it boosts your efficiency and leaves the end user with no room for error. [more info]
Rating:
Author: MIKROE
Last Updated: 2019-02-21
Package Version: 1.0.0.0
mikroSDK Library: 1.0.0.0
Category: Measurements
Downloaded: 3619 times
Not followed.
License: MIT license
Analog Key Click is an analog keyboard on a Click board. It contains six tactile pushbuttons, used to select one of six different voltage levels.
Do you want to subscribe in order to receive notifications regarding "Analog Key click" changes.
Do you want to unsubscribe in order to stop receiving notifications regarding "Analog Key click" changes.
Do you want to report abuse regarding "Analog Key click".
Library Description
The library contains a function which, based on the ADC value, detects which button is pressed.
Key functions:
uint8_t analogkey_getKey(uint16_t adcValue)
- Detects which button is pressed.Examples description
The application is composed of the three sections :
void applicationTask()
{
uint16_t ADC_value;
uint8_t isKey;
char demoText[ 50 ];
uint8_t cnt;
uint16_t sumValue = 0;
for(cnt = 0; cnt < 5; cnt++)
{
ADC_value = analogkey_adcRead();
sumValue += ADC_value;
Delay_10ms();
}
ADC_value = sumValue / 5;
isKey = analogkey_getKey(ADC_value);
if(isKey != _ANALOGKEY_NO_TOUCH)
{
IntToStr(isKey, demoText);
mikrobus_logWrite("Pressed the button : ", _LOG_TEXT);
mikrobus_logWrite(demoText, _LOG_LINE);
}
Delay_ms( 300 );
}
Other mikroE Libraries used in the example:
ADC
UART
Additional notes and informations
Depending on the development board you are using, you may need USB UART click, USB UART 2 clickor RS232 click to connect to your PC, for development systems with no UART to USB interface available on the board. The terminal available in all MikroElektronika compilers, or any other terminal application of your choice, can be used to read the message.