TOP Contributors

  1. MIKROE (2654 codes)
  2. Alcides Ramos (352 codes)
  3. Shawon Shahryiar (307 codes)
  4. jm_palomino (112 codes)
  5. Chisanga Mumba (90 codes)
  6. S P (73 codes)
  7. dany (71 codes)
  8. MikroBUS.NET Team (35 codes)
  9. NART SCHINACKOW (34 codes)
  10. Armstrong Subero (27 codes)

Most Downloaded

  1. Timer Calculator (136746 times)
  2. FAT32 Library (69953 times)
  3. Network Ethernet Library (55942 times)
  4. USB Device Library (46267 times)
  5. Network WiFi Library (41887 times)
  6. FT800 Library (41174 times)
  7. GSM click (28986 times)
  8. PID Library (26414 times)
  9. mikroSDK (26363 times)
  10. microSD click (25377 times)
Libstock prefers package manager

Package Manager

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]

< Back
mikroSDK Library

Button Y click

Rating:

0

Author: MIKROE

Last Updated: 2024-04-03

Package Version: 2.1.0.11

mikroSDK Library: 2.0.0.0

Category: Pushbutton/Switches

Downloaded: 61 times

Not followed.

License: MIT license  

Button Y click 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. Although it sounds simple, a button needs to comply with a range of application requirements. It needs to have a very good mechanical endurance while retaining its specifications, a predictable bouncing time, a very low ON resistance, very high OFF resistance, and it needs to fulfill aesthetical requirements.

No Abuse Reported

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".

  • mikroSDK Library 1.0.0.0
  • Comments (0)

mikroSDK Library Blog


Button Y click

Button Y click 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. Although it sounds simple, a button needs to comply with a range of application requirements. It needs to have a very good mechanical endurance while retaining its specifications, a predictable bouncing time, a very low ON resistance, very high OFF resistance, and it needs to fulfill aesthetical requirements.

button_y_click.png

click Product page


Click library

  • Author : Nikola Peric
  • Date : Feb 2022.
  • Type : PWM type

Software Support

We provide a library for the ButtonY Click as well as a demo application (example), developed using MikroElektronika compilers. The demo can run on all the main MikroElektronika development boards.

Package can be downloaded/installed directly from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on Mikroe github account.

Library Description

This library contains API for ButtonY Click driver.

Standard key functions :

  • buttony_cfg_setup Config Object Initialization function.

    void buttony_cfg_setup ( buttony_cfg_t *cfg );
  • buttony_init Initialization function.

    err_t buttony_init ( buttony_t *ctx, buttony_cfg_t *cfg );

Example key functions :

  • buttony_pwm_stop This function stops the PWM moudle output.

    err_t buttony_pwm_stop ( buttony_t *ctx );
  • buttony_pwm_start This function starts the PWM moudle output.

    err_t buttony_pwm_start ( buttony_t *ctx );
  • buttony_get_button_state This function reads the digital signal from the INT pin which tells us whether the button has been pressed or not.

    uint8_t buttony_get_button_state ( buttony_t *ctx );

Example Description

This library contains API for Button Y Click driver. One library is used for every single one of them. They are simple touch detectors that send a pressed/released signal and receive a PWM output which controls the backlight on the button.

The demo application is composed of two sections :

Application Init

This function initializes and configures the logger and click modules.


void application_init ( void )  
{
    log_cfg_t log_cfg;          /**< Logger config object. */
    buttony_cfg_t buttony_cfg;  /**< Click config object. */

    /** 
     * 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 " );

    // Click initialization.

    buttony_cfg_setup( &buttony_cfg );
    BUTTONY_MAP_MIKROBUS( buttony_cfg, MIKROBUS_1 );
    err_t init_flag  = buttony_init( &buttony, &buttony_cfg );
    if ( PWM_ERROR == init_flag ) 
    {
        log_error( &logger, " Application Init Error. " );
        log_info( &logger, " Please, run program again... " );

        for ( ; ; );
    }
    Delay_ms ( 500 );

    buttony_set_duty_cycle ( &buttony, 0.0 );
    buttony_pwm_start( &buttony );

    log_info( &logger, " Application Task " );
}

Application Task

This example first increases the backlight on the button and then decreases the intensity of backlight. When the button is pressed, reports the event in the console using UART communication.


void application_task ( void ) 
{
    static float duty_cycle;
    static uint8_t button_state;
    static uint8_t button_state_old;

    button_state = buttony_get_button_state( &buttony );

    if ( button_state && ( button_state != button_state_old ) ) 
    {
        log_printf( &logger, " <-- Button pressed --> \r\n" );
        for ( uint8_t n_cnt = 1; n_cnt <= 100; n_cnt++  )
        {
            duty_cycle = ( float ) n_cnt ;
            duty_cycle /= 100;
            buttony_set_duty_cycle( &buttony, duty_cycle );
            Delay_ms ( 10 );
        }
        button_state_old = button_state;
    } 
    else if ( !button_state && ( button_state != button_state_old ) ) 
    {
        for ( uint8_t n_cnt = 100; n_cnt > 0; n_cnt-- )
        {
            duty_cycle = ( float ) n_cnt ;
            duty_cycle /= 100;
            buttony_set_duty_cycle( &buttony,  duty_cycle );
            Delay_ms ( 10 );
        }
        button_state_old = button_state;
    }
}

The full application code, and ready to use projects can be installed directly from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on Mikroe github account.

Other Mikroe Libraries used in the example:

  • MikroSDK.Board
  • MikroSDK.Log
  • Click.ButtonY

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. UART terminal is available in all MikroElektronika compilers.


ALSO FROM THIS AUTHOR

Joystick click

0

Simple demonstration of using AS5013 chip. If joystick is moved, cross will move on GLCD folowing joystick's move. When joystick is pressed frame around cross will appear. Example demonstrates writing and reading from AS5013 chip.

[Learn More]

Thermo 25 click

0

Thermo 25 Click is a compact add-on board that accurately measures temperature. This board features the TMP127-Q1, a high-precision digital temperature sensor from Texas Instruments. This SPI-configurable factory-calibrated temperature sensor has a high accuracy of 0.8°C, supporting an ambient temperature range from -55°C to 175°C. It features a 14-bit signed temperature resolution (0.03125 °C per LSB) while operating over a supply range.

[Learn More]

Current 6 click

0

Current 6 Click is a compact add-on board providing a precise and accurate current sensing solution. This board features the MAX40080, a fast-response bi-directional current-sense amplifier from Analog Devices. The device features ultra-low 5uV input offset voltage, very-low 0.2% gain error, and includes an analog-to-digital converter with programmable sample rate and 12-bit resolution featuring I2C compatible interface. It also features a wake-up current-threshold and auto-shutdown mode when the I2C is inactive, both designed to minimize power consumption. The current-shunt monitor can measure voltage signals on common-mode voltages ranging from -0.1V (ground sensing) to 36V, independent of the supply voltage. This Click board™ delivers higher performance to industrial control and automation applications, load and power supplies monitoring, telecom equipment, and many more.

[Learn More]