Explore how this innovative microswitch design can enhance your device's functionality, delivering signals in both pressed and released positions
A
A
Hardware Overview
How does it work?
Tamper 2 Click is based on the D2HW-A221D, a microswitch from Omron, specifically positioned on the board so it is easily accessible for interacting with various objects that could press the lever, activating the microswitch that way. The microswitch is actuated by applying very little physical force, using a tipping-point mechanism which results in fast and reliable snap-in action. It also has both NC and NO contacts routed to the
mikroBUS™ so both states of the switch can be detected. Both lines are equipped with the RC filters, which serve as debouncing elements for the switch and also to pull down the lines when they are left afloat. This way, the contact bouncing is reduced even further, resulting in an accurate detection of the switching event. The switch itself is very endurable and its rated up to 42VDC / 0.5A, also can endure a very high number of
switching cycles – up to 1000000. 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
Flip&Click PIC32MZ is a compact development board designed as a complete solution that brings the flexibility of add-on Click boards™ to your favorite microcontroller, making it a perfect starter kit for implementing your ideas. It comes with an onboard 32-bit PIC32MZ microcontroller, the PIC32MZ2048EFH100 from Microchip, four mikroBUS™ sockets for Click board™ connectivity, two USB connectors, LED indicators, buttons, debugger/programmer connectors, and two headers compatible with Arduino-UNO pinout. Thanks to innovative manufacturing technology,
it allows you to build gadgets with unique functionalities and features quickly. Each part of the Flip&Click PIC32MZ development kit contains the components necessary for the most efficient operation of the same board. In addition, there is the possibility of choosing the Flip&Click PIC32MZ programming method, using the chipKIT bootloader (Arduino-style development environment) or our USB HID bootloader using mikroC, mikroBasic, and mikroPascal for PIC32. This kit includes a clean and regulated power supply block through the USB Type-C (USB-C) connector. All communication
methods that mikroBUS™ itself supports are on this board, including the well-established mikroBUS™ socket, user-configurable buttons, and LED indicators. Flip&Click PIC32MZ development kit allows you to create a new application in minutes. Natively supported by Mikroe software tools, it covers many aspects of prototyping thanks to a considerable number of different Click boards™ (over a thousand boards), the number of which is growing every day.
Microcontroller Overview
MCU Card / MCU

Architecture
PIC32
MCU Memory (KB)
2048
Silicon Vendor
Microchip
Pin count
100
RAM (Bytes)
524288
Used MCU Pins
mikroBUS™ mapper
Take a closer look
Click board™ Schematic

Step by step
Project assembly
Software Support
Library Description
This library contains API for Tamper 2 Click driver.
Key functions:
tamper2_get_on_state- Switch ON detecttamper2_get_off_state- Switch OFF detect
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
* \brief Tamper 2 Click example
*
* # Description
* This application sets switch on ON or OFF.
*
* The demo application is composed of two sections :
*
* ## Application Init
* Sends HAL pointers
*
* ## Application Task
* Detects whether the state of switch on Tamper 2 Click is ON or OFF.
*
* \author MikroE Team
*
*/
// ------------------------------------------------------------------- INCLUDES
#include "board.h"
#include "log.h"
#include "tamper2.h"
// ------------------------------------------------------------------ VARIABLES
static tamper2_t tamper2;
static log_t logger;
// ------------------------------------------------------ APPLICATION FUNCTIONS
void application_init ( void )
{
log_cfg_t log_cfg;
tamper2_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.
tamper2_cfg_setup( &cfg );
TAMPER2_MAP_MIKROBUS( cfg, MIKROBUS_1 );
tamper2_init( &tamper2, &cfg );
}
void application_task ( )
{
uint8_t on_state;
uint8_t off_state;
on_state = tamper2_get_on_state( &tamper2 );
off_state = tamper2_get_off_state( &tamper2 );
if ( on_state == 1 )
{
log_printf( &logger, "Tamper 2 Click is in ON state.\r\n" );
}
if ( off_state == 1 )
{
log_printf( &logger, "Tamper 2 Click is in OFF state.\r\n" );
}
Delay_ms ( 200 );
}
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

































