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: 2018-11-26
Package Version: 1.0.0.0
mikroSDK Library: 1.0.0.0
Category: Pushbutton/Switches
Downloaded: 3813 times
Not followed.
License: MIT license
Button Y is a Click board equipped with the tactile switch, sometimes referred to as a pushbutton. A pushbutton is a component that is used very often in various designs, allowing the user to interact with the application.
Do you want to subscribe in order to receive notifications regarding "Button Y click" changes.
Do you want to unsubscribe in order to stop receiving notifications regarding "Button Y click" changes.
Do you want to report abuse regarding "Button Y click".
Library Description
The library contains a function that checks and returns the state of the button - whether it is pressed or not. Using the PWM function, you can adjust the LED light button.
Key functions:
uint8_t buttony_getButtonState()
- Functions for Get Button stateExamples description
The application is composed of the three sections :
void applicationTask()
{
buttonState = buttony_getButtonState();
if ((buttonState == _BUTTONY_BUTTON_IS_PRESSED) && (_pressFlag == 0))
{
_pressFlag = 1;
}
if (_pressFlag == 0)
{
_dutyCycle += 250;
buttony_pwmSetDuty(_dutyCycle);
if (_dutyCycle > 10000 )
{
_dutyCycle = 0;
buttony_pwmSetDuty(_dutyCycle);
Delay_ms(2000);
}
Delay_ms( 50 );
}
else
{
if(buttonState == _BUTTONY_BUTTON_IS_PRESSED)
{
mikrobus_logWrite(" Button is pressed ", _LOG_LINE);
buttony_pwmSetDuty(10000);
Delay_ms( 2000 );
}
else
{
buttony_pwmSetDuty(0);
}
}
}
Other mikroE Libraries used in the example:
PWM
Additional notes and information
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.