Introduction

This is a multifunctional Arduino/Seeeduino/Arduino Mega compatible resistive touch screen shield which can be used as display device, or sketch pad for user input/interface.

Compared with the previous version (2.8" TFT Touch Shield V1.0) we improved the screen driver with a professional chip (ILI9341) to provide the pin-saving SPI communication protocol without sacrificing the data transmission speed.

An SD card module is also integrated in the shield to provide storage space, and anything else you can think of, for your projects.

Code Explained

Let us show you how to use the drawCircle and fillCircle functions.

drawCircle:

Function Heading: drawCircle(int poX, int poY, int r, INT16U color)

Function Description: The drawCircle function draws an empty circle with the center at the coordinates poX, and poY. The circle will be of radius r and the border color will be color. The color parameter is a 16-bit Red-Geen-Blue (RGB) integer, in the example code above the words YELLOW, CYAN, RED, and BLUE are defined as integers in the TFTv2.h file.

RGB Integers: A 16-bit RGB integer specifies the amount of red, green, and blue to form a color. From right to left, bits 0-4, 5-10, and 11-15 specify the amount of blue, green, and red. For example, if you want to specify white as the color this will require an equal amount of red, green, and blue therefore the RGB integer for white will be 0xffff.

These are the colors defined in the TFT Touch Shield V2 library, but you can make your own of course:

Example #3: Sketch Pad

This example shows how to make a sketch pad, with touch brushes of different colors.

Open the “paint” the same way you opened the ”drawCircle” example above.

Upload the code to the Arduino board.

A color palette should be displayed on the right side of the screen to give the user different colors to choose from for his/her finger brush. The colors available in the palette are BLACK, RED, GREEN, BLUE, CYAN, YELLOW, WHITE, and GRAY1. Check out our artistic skills below!

Smiley face we made using the TFT shield as a sketch pad

Note: To clear the screen/canvas, simply press the reset button or power off and then power-on the Shield.

Example #4: Backlight Control

The TFT Touch Shield's backlight is on by default since its control circuit is directly powered by the 5V pin. If however, you wish to control the backlight's on/off state using the Arduino Digital I/O pin 7, a simple modification will have to be made:

Note: Please read ALL of the following steps first before performing any action.

1. Find the backlight's three terminals location (ON, BACKLIGHT, D7) in the back/bottom side of the shield (see figure below).

Backlight terminals location.

2. Notice that the ON terminal is soldered to the BACKLIGHT terminal as shown in the PCB figure below. Scrape off this connection, or use a soldering iron to remove it.

The default connection of the backlight (ON connected to BACKLIGHT).

3. Now solder the D7 terminal to the BACKLIGHT terminal as shown in the PCB figure below.

The required modification to control the backlight using digital pin 7 (connect BACKLIGHT to D7)

Now controlling the backlight's state is as easy as controlling an LED, upload the following code to the Arduino board to see how to toggle the backlight every 500ms (1/2 second):