TOP Contributors

  1. MIKROE (2751 codes)
  2. Alcides Ramos (372 codes)
  3. Shawon Shahryiar (307 codes)
  4. jm_palomino (118 codes)
  5. Bugz Bensce (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 (139050 times)
  2. FAT32 Library (71588 times)
  3. Network Ethernet Library (56988 times)
  4. USB Device Library (47326 times)
  5. Network WiFi Library (43005 times)
  6. FT800 Library (42295 times)
  7. GSM click (29754 times)
  8. mikroSDK (27873 times)
  9. PID Library (26858 times)
  10. microSD click (26129 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

CAP Slider 2 Click

Rating:

0

Author: MIKROE

Last Updated: 2024-10-31

Package Version: 2.1.0.18

mikroSDK Library: 2.0.0.0

Category: Capacitive

Downloaded: 151 times

Not followed.

License: MIT license  

This application use for controlling various devices

No Abuse Reported

Do you want to subscribe in order to receive notifications regarding "CAP Slider 2 Click" changes.

Do you want to unsubscribe in order to stop receiving notifications regarding "CAP Slider 2 Click" changes.

Do you want to report abuse regarding "CAP Slider 2 Click".

  • mikroSDK Library 1.0.0.0
  • Comments (0)

mikroSDK Library Blog


CAP Slider 2 Click

CAP Slider 2 Click is a capacitive touch sensor with XY cross shaped electrodes integrated on a Click board™. This Click can sense touch even through plastic, wood, or other dielectric materials, which can be used to protect the surface of the PCB and the sensor pad trace itself

capslider2_click.png

Click Product page


Click library

  • Author : MikroE Team
  • Date : Jan 2020.
  • Type : I2C type

Software Support

We provide a library for the CapSlider2 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 form compilers IDE(recommended way), or downloaded from our LibStock, or found on mikroE github account.

Library Description

This library contains API for CapSlider2 Click driver.

Standard key functions :

  • Config Object Initialization function.

    void capslider2_cfg_setup ( capslider2_cfg_t *cfg );

  • Initialization function.

    CAPSLIDER2_RETVAL capslider2_init ( capslider2_t ctx, capslider2_cfg_t cfg );

Example key functions :

  • Generic Write function

    uint8_t capsldr2_write_reg ( capslider2_t ctx, uint8_t register_address, uint8_t data_in, uint8_t n_bytes );

  • Generic Read function

    uint8_t capsldr2_read_reg ( capslider2_t ctx, uint8_t register_address, uint8_t data_out, uint8_t n_bytes );

  • Data Ready Check function

    uint8_t capsldr2_check_data_ready ( capslider2_t *ctx );

Examples Description

This application could be used for controlling various devices.

The demo application is composed of two sections :

Application Init

Initializes I2C interface, performs the device reset and configurations and sets the desired threshold value which determines sensor sensitivity.


void application_init ( void )
{
    log_cfg_t log_cfg;
    capslider2_cfg_t cfg;

    /** 
     * 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.

    capslider2_cfg_setup( &cfg );
    CAPSLIDER2_MAP_MIKROBUS( cfg, MIKROBUS_1 );
    capslider2_init( &capslider2, &cfg );

    Delay_ms ( 500 );

    cnt = 0;
    wheel_avrg1 = 0;
    wheel_avrg2 = 0;

    capsldr2_reset( &capslider2 );
    Delay_ms ( 500 );

    capsldr2_enable_chann( &capslider2, CAPSLDR2_CH0_PROX_EN | CAPSLDR2_CH1_EN | CAPSLDR2_CH2_EN | CAPSLDR2_CH3_EN | CAPSLDR2_CH4_EN | CAPSLDR2_CH5_EN | CAPSLDR2_CH6_EN | CAPSLDR2_CH7_EN | CAPSLDR2_CH8_EN | CAPSLDR2_CH9_EN );
    capsldr2_config( &capslider2 );
    capsldr2_set_threshold( &capslider2, 0x04 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );

    log_printf( &logger, "CAP Slider 2 is initialized\r\n" );

}

Application Task

Checks for data ready and then read capacitance from all channels. There are two sliders on the clik board (X and Y). X slider selects which LEDs are being activated, while Y slider increases/decreases the LEDs intensity.


void application_task ( void )
{
    uint16_t data_wheel1;
    uint16_t data_wheel2;
    uint8_t ready_check;

    ready_check = capsldr2_check_data_ready( &capslider2 );

    if (ready_check == CAPSLDR2_DATA_READY)
    {
        capsldr2_get_data( &capslider2, &data_wheel1, &data_wheel2 );

        wheel_avrg1 += data_wheel1;
        wheel_avrg2 += data_wheel2;
        cnt++;
    }

    if (cnt == 1)
    {
        if ((wheel_avrg2 / cnt) > 1800)
        {
            horizontal_check(  );
            capsldr2_set_output( &capslider2, out_val, out_mode );
        }
        else if (((wheel_avrg2 / cnt) < 1650) && ((wheel_avrg2 / cnt) > 1000))
        {
            vertical_check(  );
            capsldr2_set_output( &capslider2, out_val, out_mode );
        }

        wheel_avrg1 = 0;
        wheel_avrg2 = 0;
        cnt = 0;
    }
}  

Note

In some cases, the user will need to wait several seconds after the Click initialization for the sensor to be stabilized.

The full application code, and ready to use projects can be installed directly form compilers IDE(recommneded) or found on LibStock page or mikroE GitHub accaunt.

Other mikroE Libraries used in the example:

  • MikroSDK.Board
  • MikroSDK.Log
  • Click.CapSlider2

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.


ALSO FROM THIS AUTHOR

PROFET 2 3A Click

0

PROFET 2 Click is a compact add-on board that contains a smart high-side power switch. This board features the BTS70802EPAXUMA1, a dual-channel, high-side power switch with embedded protection and diagnosis feature from Infineon Technologies.

[Learn More]

Hall Current 15 Click

0

Hall Current 15 Click is a compact add-on board that provides precise AC or DC current-sensing solution. This board features the TMCS1101-Q1, a galvanically isolated Hall-effect current sensor capable of DC or AC current measurement with high accuracy, excellent linearity, and temperature stability from Texas Instruments. A low-drift, temperature-compensated signal chain provides <1.5% full-scale error across a broad operating temperature range. It also provides a reliable 600V lifetime working voltage and 3kVRMS isolation between the current path and circuitry with uni/bidirectional current sensing. Besides, the user is allowed to process the output signal in analog or digital form.

[Learn More]

RFid Lock with 4 Relays

11

Using PIC-Ready1 with PIC18F4520, RFid reader, Relay 4 board, along with EasyInput and EasyBuzz we have created a simple RFid lock that controls 4 separate relays with RFid cards. And it will cost you less than $100 USD!

[Learn More]