Add a Multi-Touch Display Module to Arduino Mega

This project shows how to use Digilent Pmod MTDS, a capacitive touchscreen, with multi-touch support, with Arduino Mega. In this demonstration, after displaying some text messages, different shapes will be displayed. By touching the display with two fingers, the shape can be changed, and by swiping across the screen with one finger, the color of the shape can be set.

Pmod MTDS

The Pmod MTDS is a 2.8″ capacitive touchscreen with multi-touch support up to 2 fingers. The display has QVGA (320×240) resolution, a micro-SD card slot and is controlled by an on-board PIC32MZ microcontroller,  which is running the firmware. Communication with the on-board microcontroller can be realized by using the SPI interface. Thanks to the Multi-Touch Display System (MTDS) Firmware and associated libraries, you can get started with Pmod MTDS easily.

Installing and using the libraries

To install the libraries, you have to copy the content of the Libraries folder to the path which is given in the Arduino IDE (%userprofile%\Documents\Arduino\libraries on Windows). The MTDS library package contains four folders: Documentation, Libraries, Resources, and Sketches. For this project the two libraries are used: mtds.h and MyDisp.h. The mtds.h library contains the full set of available functions for the Pmod MTDS, while the MyDisp.h library contains a limited set, but easier to use functions.

Interfacing Pmod MTDS with Arduino Mega

The Pmod MTDS communicates with Arduino Mega via SPI. However, the implementation of this physical interface is handled by the MTDS libraries, so the user doesn’t have to directly use this protocol. The module is powered by 3.3V supplied by the Arduino Mega.

 

To connect the Pmod to the Arduino Mega, connect:

VCC to 3V3
GND to GND
SCLK to 52 (SCK)
MISO to 50 (MISO)
MOSI to 51 (MOSI)
CS to 53 (SS)

Arduino Sketch

A text message will be displayed on the screen, using the Console font, the text being green and the background being black (Matrix-style). After three seconds this text is deleted, then a red rectangle is displayed. In the main loop, in every iteration, it is checked if the display was touched or not. If a new action is detected, the type of the touch is determined based on the MTDS’s default messaging system (an object stores the touch type and the position coordinates). The shape and the color of the object are then determined from these actions, finally the screen is refreshed.

Results

Get all the project details and the Arduino code on the project page.

The Digilent Pmod MTDS is available in Farnell.