Intermediate
30 min

Elevate your user experience with our smart joystick and MK64FN1M0VDC12 combo

Empowering your adventures, one tilt at a time

Joystick 2 Click with Clicker 2 for Kinetis

Published Oct 17, 2023

Click board™

Joystick 2 Click

Dev Board

Clicker 2 for Kinetis

Compiler

NECTO Studio

MCU

MK64FN1M0VDC12

Experience the future of navigation with the smart joystick concept, providing users with a seamless and intuitive way to explore digital worlds

A

A

Hardware Overview

How does it work?

Joystick 2 Click is based on the SKRHABE01, a 4-direction joystick switch with Center-push Function from Alps Alpine. It is positioned on the board so it is easily accessible for interacting and the lever could be pressed, 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 has both NO (Normal open) contacts routed to the mikroBUS™ over the port expander. The switch lines are equipped with the RC filters, which serve as debouncing

elements for the switch and also to pull-up 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. As already mentioned above, this click board™ contains the port expander, relatively large number of needed GPIO pins for the joystick switch. Used IC is PCA9538A, Low-voltage 8-bit I2C-bus I/O port with interrupt and reset, from NXP Semiconductors. It uses the I2C communication for interfacing with the main MCU, which simplifies the number of needed pins,

and therefore the design itself. The Active LOW reset input (RESET) and Open-drain active LOW interrupt output (INT) pins helps simplifying the design even further. 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.

Joystick 2 Click top side image
Joystick 2 Click bottom side image

Features overview

Development board

Clicker 2 for Kinetis is a compact starter development board 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 ARM Cortex-M4F microcontroller, the MK64FN1M0VDC12 from NXP Semiconductors, two mikroBUS™ sockets for Click board™ connectivity, a USB connector, LED indicators, buttons, a JTAG programmer connector, and two 26-pin headers for interfacing with external electronics. Its compact design with clear and easily recognizable silkscreen markings allows you to build gadgets with unique functionalities and

features quickly. Each part of the Clicker 2 for Kinetis development kit contains the components necessary for the most efficient operation of the same board. In addition to the possibility of choosing the Clicker 2 for Kinetis programming method, using a USB HID mikroBootloader or an external mikroProg connector for Kinetis programmer, the Clicker 2 board also includes a clean and regulated power supply module for the development kit. It provides two ways of board-powering; through the USB Micro-B cable, where onboard voltage regulators provide the appropriate voltage levels to each component on the board, or

using a Li-Polymer battery via an onboard battery connector. All communication methods that mikroBUS™ itself supports are on this board, including the well-established mikroBUS™ socket, reset button, and several user-configurable buttons and LED indicators. Clicker 2 for Kinetis is an integral part of the Mikroe ecosystem, allowing 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.

Clicker 2 for Kinetis dimensions image

Microcontroller Overview

MCU Card / MCU

default

Architecture

ARM Cortex-M4

MCU Memory (KB)

1024

Silicon Vendor

NXP

Pin count

121

RAM (Bytes)

262144

Used MCU Pins

mikroBUS™ mapper

NC
NC
AN
Reset
PB11
RST
NC
NC
CS
NC
NC
SCK
NC
NC
MISO
NC
NC
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
NC
NC
PWM
Interrupt
PB13
INT
NC
NC
TX
NC
NC
RX
I2C Clock
PD8
SCL
I2C Data
PD9
SDA
Power Supply
5V
5V
Ground
GND
GND
1

Take a closer look

Schematic

Joystick 2 Click Schematic schematic

Step by step

Project assembly

Clicker 2 for PIC32MZ front image hardware assembly

Start by selecting your development board and Click board™. Begin with the Clicker 2 for Kinetis as your development board.

Clicker 2 for PIC32MZ front image hardware assembly
Buck 22 Click front image hardware assembly
Prog-cut hardware assembly
Micro B Connector Clicker 2 - upright/background hardware assembly
Necto image step 2 hardware assembly
Necto image step 3 hardware assembly
Necto image step 4 hardware assembly
Necto image step 5 hardware assembly
Necto image step 6 hardware assembly
Flip&Click PIC32MZ MCU step hardware assembly
Necto No Display image step 8 hardware assembly
Necto image step 9 hardware assembly
Necto image step 10 hardware assembly
Debug Image Necto Step hardware assembly

Track your results in real time

Application Output via Debug Mode

1. Once the code example is loaded, pressing the "DEBUG" button initiates the build process, programs it on the created setup, and enters Debug mode.

2. After the programming is completed, a header with buttons for various actions within the IDE becomes visible. Clicking the green "PLAY" button starts reading the results achieved with the Click board™. The achieved results are displayed in the Application Output tab.

DEBUG_Application_Output

Software Support

Library Description

This library contains API for Joystick 2 Click driver.

Key functions:

  • joystick2_set_cfg_register - Functions for configuration joystick

  • joystick2_get_position - Functions for get Joystick position

  • joystick2_get_interrupt_state - Functions for read interrupt state

Open Source

Code example

This example can be found in NECTO Studio. Feel free to download the code, or you can copy the code below.

/*!
 * \file 
 * \brief Joystick2 Click example
 * 
 * # Description
 * The demo application shows reading the joistick position ..
 *
 * The demo application is composed of two sections :
 * 
 * ## Application Init 
 * Configuring clicks and log objects.
 * Reset device and settings the click in the default configuration.
 * 
 * ## Application Task  
 * It reads the position of the joystick,
 * if it detects that the joystick has moved from the zero position,
 * it prints a message about the current position.
 *
 * @note: The I2C peripheral lines external pull up can be required.
 * 
 * \author Katarina Perendic
 *
 */
// ------------------------------------------------------------------- INCLUDES

#include "board.h"
#include "log.h"
#include "joystick2.h"

// ------------------------------------------------------------------ VARIABLES

static joystick2_t joystick2;
static log_t logger;

// ------------------------------------------------------ APPLICATION FUNCTIONS

void application_init ( void )
{
    log_cfg_t log_cfg;
    joystick2_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.

    joystick2_cfg_setup( &cfg );
    JOYSTICK2_MAP_MIKROBUS( cfg, MIKROBUS_1 );
    joystick2_init( &joystick2, &cfg );

    joystick2_reset( &joystick2 );
    joystick2_default_cfg( &joystick2 );
    log_info( &logger, "---- JOYSTICK START ----" );
}

void application_task ( void )
{
    uint8_t joystick_pos;

    //  Task implementation.

    joystick_pos = joystick2_get_position( &joystick2 );

    switch ( joystick_pos )
    {
        case JOYSTICK2_BUTTON_ACTIVE:
        {
            log_info( &logger, "--- Button is pressed!!! ---" );
            Delay_ms( 300 );
            break;
        }
        case JOYSTICK2_POSITION_RIGHT:
        {
            log_info( &logger, "--- Joystick position [RIGHT] ---" );
            Delay_ms( 300 );
            break;
        }
        case JOYSTICK2_POSITION_LEFT:
        {
            log_info( &logger, "--- Joystick position [LEFT] ---" );
            Delay_ms( 300 );
            break;
        }
        case JOYSTICK2_POSITION_UP:
        {
            log_info( &logger, "--- Joystick position [UP] ---" );
            Delay_ms( 300 );
            break;
        }
        case JOYSTICK2_POSITION_DOWN:
        {
            log_info( &logger, "--- Joystick position [DOWN] ---" );
            Delay_ms( 300 );
            break;
        }
    }
}

void main ( void )
{
    application_init( );

    for ( ; ; )
    {
        application_task( );
    }
}


// ------------------------------------------------------------------------ END

Additional Support

Resources

Love this project?

'Buy This Kit' button takes you directly to the shopping cart where you can easily add or remove products.