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-07-26
Package Version: 1.0.0.0
mikroSDK Library: 1.0.0.0
Category: Pushbutton/Switches
Downloaded: 3312 times
Not followed.
License: MIT license
Keylock 2 Click carries antistatic process sealed keylock mechanism that has three positions. This board is intended to be used for implementation into applications which require mechanical lock mechanism, as well as for testing the same concepts in early development stage.
Do you want to subscribe in order to receive notifications regarding "Keylock 2 click" changes.
Do you want to unsubscribe in order to stop receiving notifications regarding "Keylock 2 click" changes.
Do you want to report abuse regarding "Keylock 2 click".
Library Description
The library contains a function for reading the state of a pin and a function that, based on the state of 3 pins - detects the position of the key.
Key functions:
uint8_t keylock2_getPinState(uint8_t pin)
- Get Pin State.uint8_t keylock2_getPosition()
- Get Key Position.Examples description
The application is composed of three sections :
void applicationTask()
{
keyPosition = keylock2_getPosition();
if(oldPosition != keyPosition)
{
if(keyPosition == _KEYLOCK2_POSITION_1)
{
mikrobus_logWrite(" -- FIRST position -- ", _LOG_LINE);
}
else if(keyPosition == _KEYLOCK2_POSITION_2)
{
mikrobus_logWrite(" -- SECOND position -- ", _LOG_LINE);
}
else
{
mikrobus_logWrite(" -- THIRD position -- ", _LOG_LINE);
}
}
oldPosition = keyPosition;
Delay_ms( 500 );
}
Other mikroE Libraries used in the example:
Additional notes and informations
Depending on the development board you are using, you may need USB UART click, USB UART 2 click or 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.