TOP Contributors

  1. MIKROE (2784 codes)
  2. Alcides Ramos (385 codes)
  3. Shawon Shahryiar (307 codes)
  4. jm_palomino (118 codes)
  5. Bugz Bensce (97 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 (139842 times)
  2. FAT32 Library (72209 times)
  3. Network Ethernet Library (57392 times)
  4. USB Device Library (47740 times)
  5. Network WiFi Library (43364 times)
  6. FT800 Library (42700 times)
  7. GSM click (29980 times)
  8. mikroSDK (28440 times)
  9. PID Library (26989 times)
  10. microSD click (26398 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

Rotary Switch Click

Rating:

0

Author: MIKROE

Last Updated: 2024-12-10

Package Version: 2.1.0.1

mikroSDK Library: 2.0.0.0

Category: Rotary encoder

Downloaded: 17 times

Not followed.

License: MIT license  

Rotary Switch Click is a compact add-on board for applications requiring precise rotary input. This board is based on the RDS6-16S-1065-1-SMT, a 16-position notched cap surface-mount rotary DIP switch from Same Sky. This switch features continuous 360-degree actuator rotation, a 2.54mm pin pitch, and robust construction with a contact resistance of 80mΩ and a maximum operating torque of 700gf*cm, ensuring reliable operation for up to 10,000 steps. The board supports the innovative Click Snap feature, allowing the rotary switch to operate autonomously when detached, providing flexibility in various implementations.

No Abuse Reported

Do you want to subscribe in order to receive notifications regarding "Rotary Switch Click" changes.

Do you want to unsubscribe in order to stop receiving notifications regarding "Rotary Switch Click" changes.

Do you want to report abuse regarding "Rotary Switch Click".

  • Information
  • Comments (0)

mikroSDK Library Blog


Rotary Switch Click

Rotary Switch Click is a compact add-on board for applications requiring precise rotary input. This board is based on the RDS6-16S-1065-1-SMT, a 16-position notched cap surface-mount rotary DIP switch from Same Sky. This switch features continuous 360-degree actuator rotation, a 2.54mm pin pitch, and robust construction with a contact resistance of 80mΩ and a maximum operating torque of 700gf*cm, ensuring reliable operation for up to 10,000 steps. The board supports the innovative Click Snap feature, allowing the rotary switch to operate autonomously when detached, providing flexibility in various implementations.

rotaryswitch_click.png

Click Product page


Click library

  • Author : Stefan Filipovic
  • Date : Jul 2024.
  • Type : I2C type

Software Support

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

Standard key functions :

  • rotaryswitch_cfg_setup Config Object Initialization function.

    void rotaryswitch_cfg_setup ( rotaryswitch_cfg_t *cfg );
  • rotaryswitch_init Initialization function.

    err_t rotaryswitch_init ( rotaryswitch_t *ctx, rotaryswitch_cfg_t *cfg );
  • rotaryswitch_default_cfg Click Default Configuration function.

    err_t rotaryswitch_default_cfg ( rotaryswitch_t *ctx );

Example key functions :

  • rotaryswitch_get_position This function reads the rotary switch position.

    err_t rotaryswitch_get_position ( rotaryswitch_t *ctx, uint8_t *position );
  • rotaryswitch_write_reg This function writes a desired data to the selected register by using I2C serial interface.

    err_t rotaryswitch_write_reg ( rotaryswitch_t *ctx, uint8_t reg, uint8_t data_in );
  • rotaryswitch_read_reg This function reads data from the selected register by using I2C serial interface.

    err_t rotaryswitch_read_reg ( rotaryswitch_t *ctx, uint8_t reg, uint8_t *data_out );

Example Description

This example demonstrates the use of Rotary Switch Click board by reading and displaying the switch position on the USB UART.

The demo application is composed of two sections :

Application Init

Initializes the driver and performs the Click default configuration.


void application_init ( void )
{
    log_cfg_t log_cfg;  /**< Logger config object. */
    rotaryswitch_cfg_t rotaryswitch_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.
    rotaryswitch_cfg_setup( &rotaryswitch_cfg );
    ROTARYSWITCH_MAP_MIKROBUS( rotaryswitch_cfg, MIKROBUS_1 );
    if ( I2C_MASTER_ERROR == rotaryswitch_init( &rotaryswitch, &rotaryswitch_cfg ) ) 
    {
        log_error( &logger, " Communication init." );
        for ( ; ; );
    }

    if ( ROTARYSWITCH_ERROR == rotaryswitch_default_cfg ( &rotaryswitch ) )
    {
        log_error( &logger, " Default configuration." );
        for ( ; ; );
    }

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

Application Task

Reads the switch position every 20ms and displays it on the USB UART on position change.

void application_task ( void )
{
    static uint8_t old_position = 0xFF;
    uint8_t position = 0;
    if ( ( ROTARYSWITCH_OK == rotaryswitch_get_position ( &rotaryswitch, &position ) ) && 
         ( position != old_position ) )
    {
        Delay_ms ( 20 );
        // Double-check for debouncing
        if ( ( ROTARYSWITCH_OK == rotaryswitch_get_position ( &rotaryswitch, &position ) ) && 
             ( position != old_position ) )
        {
            old_position = position;
            log_printf ( &logger, " Switch position: %.1X\r\n", ( uint16_t ) position );
        }
    }
    Delay_ms ( 20 );
}

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

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

BIG 7-SEG R click

0

BIG 7-SEG R click is what you need if you want to add a seven-segment LED display to your project. This click features an SC10-21SRWA 7-segment display. Communication between the MCU and the SC10-21SRWA display is established via serial-IN, parallel-OUT shift register 74HC595 IC.

[Learn More]

RYB080I Click

0

RYB080I Click is a compact add-on board for seamless Bluetooth Low Energy (LE) communication in various wireless applications. This board features the RYB080I, a 2.4GHz Bluetooth 4.2/5.0 LE module with an integrated antenna from REYAX, based on the TI CC2640R2F ARM® Cortex®-M3 MCU. This module supports dual-device connectivity, operates in both Host and Client roles, and includes a metal cover for EMI protection, ensuring stable performance even in noisy environments. With support for the Generic Attribute Profile (GATT) and easy setup via REYAX AT commands, integration into diverse systems is simplified.

[Learn More]

Compass 3 click

5

Compass 3 Click features MMC5883MA, a complete 3-axis magnetic sensor with on-chip signal processing and integrated I2C bus suitable for use in various applications.

[Learn More]