TSC2046 Touch Screen Controller


The TI TSC2046 touch screen controller is a 16 pin controller for 4-wire resistive touch screens and panels. This wiki will go over a basic hookup and a code example to get started with the TSC2046.

Import Library

Import libraryTSC2046

Driver library for TSC2046 touch panel controller


Pinout Diagram for TSC2046 chip

/media/uploads/zachh368/tscpinout.png

Detailed information on TSC2046 operation can be found in the datasheet: http://www.ti.com/lit/ds/symlink/tsc2046.pdf

Hook-up Diagram:

Make connections as labeled in the diagram

/media/uploads/zachh368/mbedtsc2046_2.png

Completed Hook-up:

All parts for this project(found in the BOM at the bottom of this page) are sourced to work with breadboards and below is what the final hook-up should look like.

/media/uploads/zachh368/img_20170314_185623.jpg



Code Example:

TSC2046 driver code example

#include "mbed.h"
#include "TSC2046.h"
Serial pc1(USBTX, USBRX); // tx, rx
// Create SPI bus
SPI spi(p5, p6, p7);
TSC2046 TouchPad = TSC2046( spi,p8,p21);

void sayHi(){

    TouchPad.power(1);
   do{
        TouchPad.Read();
        pc1.printf("hello!\n\r x value is %d\n\r y value is %d\n\r",TouchPad.xVal,TouchPad.yVal);
        
   }while(TouchPad.state == 0);
   TouchPad.power(0);
}

int main() {
   
    TouchPad.PENIRQ.fall(&sayHi);

    while(1) {
        
        
        wait(0.1);
    }
}

The TSC2046 library uses a serial connection to print out TouchPad values to the terminal, go here: https://developer.mbed.org/handbook/Serial for more information on how to do that. The library also creates an interrupt and is called in main on line 21 using a function handle as the input.



TSC2046 Controller in Action



BOM of Parts from DigiKey

/media/uploads/zachh368/bom_for_tsc2046.csv


Please log in to post comments.