TOP Contributors

  1. MIKROE (2656 codes)
  2. Alcides Ramos (353 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 (136872 times)
  2. FAT32 Library (70000 times)
  3. Network Ethernet Library (55999 times)
  4. USB Device Library (46305 times)
  5. Network WiFi Library (41917 times)
  6. FT800 Library (41206 times)
  7. GSM click (29012 times)
  8. PID Library (26423 times)
  9. mikroSDK (26395 times)
  10. microSD click (25386 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 ALARM click

Rating:

0

Author: MIKROE

Last Updated: 2024-04-03

Package Version: 2.1.0.11

mikroSDK Library: 2.0.0.0

Category: Capacitive

Downloaded: 53 times

Not followed.

License: MIT license  

Button ALARM Click is a very interesting interactive gadget on a Click board™. It is an integrated capacitive touch sensor display in the form of a button. By utilizing an advanced capacitive touch sensing technology, the CTHS15CIC05ALARM sensor can successfully replace the traditional mechanical button, allowing very simplified yet reliable user interfaces to be developed. Besides the touch detection, this sensor also features a green power symbol icon with backlight, which makes the Click board™ very useful for building various stylized and visually appealing interfaces.

No Abuse Reported

Do you want to subscribe in order to receive notifications regarding "Button ALARM click" changes.

Do you want to unsubscribe in order to stop receiving notifications regarding "Button ALARM click" changes.

Do you want to report abuse regarding "Button ALARM click".

  • mikroSDK Library 1.0.0.0
  • Comments (0)

mikroSDK Library Blog


Button ALARM click

Button ALARM Click is a very interesting interactive gadget on a Click board™. It is an integrated capacitive touch sensor display in the form of a button. By utilizing an advanced capacitive touch sensing technology, the CTHS15CIC05ALARM sensor can successfully replace the traditional mechanical button, allowing very simplified yet reliable user interfaces to be developed. Besides the touch detection, this sensor also features a green power symbol icon with backlight, which makes the Click board™ very useful for building various stylized and visually appealing interfaces.

button_alarm_click.png

click Product page


Click library

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

Software Support

We provide a library for the ButtonAlarm 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 ButtonAlarm Click driver.

Standard key functions :

  • buttonalarm_cfg_setup Config Object Initialization function.

    void buttonalarm_cfg_setup ( buttonalarm_cfg_t *cfg );
  • buttonalarm_init Initialization function.

    err_t buttonalarm_init ( buttonalarm_t *ctx, buttonalarm_cfg_t *cfg );

Example key functions :

  • buttonalarm_pwm_stop This function stops the PWM moudle output.

    err_t buttonalarm_pwm_stop ( buttonalarm_t *ctx );
  • buttonalarm_pwm_start This function starts the PWM moudle output.

    err_t buttonalarm_pwm_start ( buttonalarm_t *ctx );
  • buttonalarm_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 buttonalarm_get_button_state ( buttonalarm_t *ctx );

Example Description

This example showcases how to initialize and use the whole family of Button clicks. 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. */
    buttonalarm_cfg_t buttonalarm_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.

    buttonalarm_cfg_setup( &buttonalarm_cfg );
    BUTTONALARM_MAP_MIKROBUS( buttonalarm_cfg, MIKROBUS_1 );
    err_t init_flag  = buttonalarm_init( &buttonalarm, &buttonalarm_cfg );
    if ( PWM_ERROR == init_flag ) 
    {
        log_error( &logger, " Application Init Error. " );
        log_info( &logger, " Please, run program again... " );

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

    buttonalarm_set_duty_cycle ( &buttonalarm, 0.1 );
    buttonalarm_pwm_start( &buttonalarm );

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

Application Task

This example first increases the backlight on the button and then decreases the intensity of the backlight. When the button is touched,
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 = buttonalarm_get_button_state( &buttonalarm );

    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;
            buttonalarm_set_duty_cycle( &buttonalarm, 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;
            buttonalarm_set_duty_cycle( &buttonalarm,  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.ButtonAlarm

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

Hall Current 8 120A click

0

Hall Current 8 Click is a compact add-on board that contains a precise solution for AC/DC current sensing. This board features the TLI4971-A120T5, a high-precision coreless current sensor for industrial/consumer applications from Infineon Technologies. The TLI4971-A120T5 has an analog interface and two fast overcurrent detection outputs, which support the protection of the power circuitry. Galvanic isolation is also provided according to the magnetic sensing principle. Infineon's monolithic Hall technology enables accurate and highly linear measurement of currents with a full scale up to 120A. This Click board™ is suitable for AC/DC current measurement applications: electrical drives, general-purpose inverters, chargers, current monitoring, overload, over-current detection, and many more.

[Learn More]

4-20mA T click

0

This code demonstrates communication via &amp;lt;b&amp;gt;4-20mA&amp;lt;/b&amp;gt; Transmitter click board. MCU reads temperature from the DS1820 sensor and prints it on the LCD. Also display shows expected current which should be measured with multimeter.

[Learn More]

Illuminance click

5

Illuminance click is a light sensor suited for detecting ambient lighting (compared too conventional light sensors that are overly sensitive to infrared). It carries TSL2561, a light-to-digital converter.

[Learn More]