Add precise rotary input with durable 16-position switching for mode selection and configurable settings
A
A
Hardware Overview
How does it work?
Rotary Switch Click is based on the RDS6-16S-1065-1-SMT, a 16-position notched cap surface-mount rotary DIP switch from Same Sky designed for applications requiring precise rotary input. This high-quality switch offers a 2.54mm pin pitch and continuous 360-degree actuator rotation, making it suitable for various user-selectable settings. Its rotary actuator, designed for durability, features a maximum operating torque of 700gf*cm and a contact resistance of 80mΩ, ensuring reliable operation with every step. The switch is rated for an operating life of approximately 10,000 steps, demonstrating its suitability for repetitive use in applications requiring consistent performance. The RDS6-16S-1065-1-SMT is designed for ease of integration, with its notched cap enabling tactile feedback at each position, providing precise manual control over adjustments. The compact
form makes it ideal for space-constrained designs, while the robust construction ensures it can withstand demanding operating environments. Its reliable performance and long lifespan make it an excellent choice for applications ranging from mode selection in industrial equipment to user-configurable settings in consumer electronics or control interfaces in automotive systems. This Click board™ is designed in a unique format supporting the newly introduced MIKROE feature called "Click Snap." Unlike the standardized version of Click boards, this feature allows the main sensor area to become movable by breaking the PCB, opening up many new possibilities for implementation. Thanks to the Snap feature, the RDS6-16S-1065-1-SMT can operate autonomously by accessing its signals directly on the pins marked 1-8. Additionally, the Snap part includes a specified and fixed screw hole
position, enabling users to secure the Snap board in their desired location. This Click board™ connects to the host MCU via the TCA9536, a 4-bit general-purpose I/O expander from Texas Instruments. Using the I2C communication protocol, the TCA9536 enables straightforward monitoring of the switch's position by reporting its state to the host MCU. This integration simplifies interpreting the switch's output, reducing the need for additional hardware or complex wiring.This Click board™ can operate with either 3.3V or 5V logic voltage levels selected via the VCC SEL jumper. This way, both 3.3V and 5V capable MCUs can use the communication lines properly. Also, this Click board™ comes equipped with a library containing easy-to-use functions and an example code that can be used as a reference for further development.
Features overview
Development board
Nucleo 32 with STM32F031K6 MCU board provides an affordable and flexible platform for experimenting with STM32 microcontrollers in 32-pin packages. Featuring Arduino™ Nano connectivity, it allows easy expansion with specialized shields, while being mbed-enabled for seamless integration with online resources. The
board includes an on-board ST-LINK/V2-1 debugger/programmer, supporting USB reenumeration with three interfaces: Virtual Com port, mass storage, and debug port. It offers a flexible power supply through either USB VBUS or an external source. Additionally, it includes three LEDs (LD1 for USB communication, LD2 for power,
and LD3 as a user LED) and a reset push button. The STM32 Nucleo-32 board is supported by various Integrated Development Environments (IDEs) such as IAR™, Keil®, and GCC-based IDEs like AC6 SW4STM32, making it a versatile tool for developers.
Microcontroller Overview
MCU Card / MCU
Architecture
ARM Cortex-M0
MCU Memory (KB)
32
Silicon Vendor
STMicroelectronics
Pin count
32
RAM (Bytes)
4096
You complete me!
Accessories
Click Shield for Nucleo-32 is the perfect way to expand your development board's functionalities with STM32 Nucleo-32 pinout. The Click Shield for Nucleo-32 provides two mikroBUS™ sockets to add any functionality from our ever-growing range of Click boards™. We are fully stocked with everything, from sensors and WiFi transceivers to motor control and audio amplifiers. The Click Shield for Nucleo-32 is compatible with the STM32 Nucleo-32 board, providing an affordable and flexible way for users to try out new ideas and quickly create prototypes with any STM32 microcontrollers, choosing from the various combinations of performance, power consumption, and features. The STM32 Nucleo-32 boards do not require any separate probe as they integrate the ST-LINK/V2-1 debugger/programmer and come with the STM32 comprehensive software HAL library and various packaged software examples. This development platform provides users with an effortless and common way to combine the STM32 Nucleo-32 footprint compatible board with their favorite Click boards™ in their upcoming projects.
Used MCU Pins
mikroBUS™ mapper
Take a closer look
Click board™ Schematic
Step by step
Project assembly
Track your results in real time
Application Output
This Click board can be interfaced and monitored in two ways:
Application Output
- Use the "Application Output" window in Debug mode for real-time data monitoring. Set it up properly by following this tutorial.
UART Terminal
- Monitor data via the UART Terminal using a USB to UART converter. For detailed instructions, check out this tutorial.
Software Support
Library Description
This library contains API for Rotary Switch Click driver.
Key functions:
rotaryswitch_get_position
- This function reads the rotary switch position.rotaryswitch_write_reg
- This function writes a desired data to the selected register by using I2C serial interface.rotaryswitch_read_reg
- This function reads data from the selected register by using I2C serial interface.
Open Source
Code example
The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.
/*!
* @file main.c
* @brief Rotary Switch Click 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.
*
* ## Application Task
* Reads the switch position every 20ms and displays it on the USB UART on position change.
*
* @author Stefan Filipovic
*
*/
#include "board.h"
#include "log.h"
#include "rotaryswitch.h"
static rotaryswitch_t rotaryswitch;
static log_t logger;
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 " );
}
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 );
}
int main ( void )
{
/* Do not remove this line or clock might not be set correctly. */
#ifdef PREINIT_SUPPORTED
preinit();
#endif
application_init( );
for ( ; ; )
{
application_task( );
}
return 0;
}
// ------------------------------------------------------------------------ END
Additional Support
Resources
Category:Pushbutton/Switches