Using the TSC2007 with Arduino involves wiring up the expander to your Arduino-compatible microcontroller, installing the Adafruit TSC2007 library and running the provided example code.

Wiring

Wire as shown for a 5V board like an Uno. If you are using a 3V board, like an Adafruit Feather, wire the board's 3V pin to the TSC2007 VIN.

Here is an Adafruit Metro wired up to the TSC2007 using the STEMMA QT connector:

  • Board 5V to sensor VIN (red wire)
  • Board GND to sensor GND (black wire)
  • Board SCL to sensor SCL (yellow wire)
  • Board SDA to sensor SDA (blue wire)

Here is an Adafruit Metro wired up using a solderless breadboard:

  • Board 5V to sensor VIN (red wire)
  • Board GND to sensor GND (black wire)
  • Board SCL to sensor SCL (yellow wire)
  • Board SDA to sensor SDA (blue wire)

Library Installation

You can install the TSC2007 library for Arduino using the Library Manager in the Arduino IDE.

adafruit_products_Arduino_Open_Library_Manager.png
arduino lib manager

Click the Manage Libraries ... menu item, search for TSC2007, and select the Adafruit TSC2007 library:

adafruit_products_crop_arduinoLib.png
tsc2007 library

If asked about dependencies, click "Install all".

adafruit_products_arduinoDependencies.png
library dependencies

If the "Dependencies" window does not come up, then you already have the dependencies installed. 

If the dependencies are already installed, you must make sure you update them through the Arduino Library Manager before loading the example!

Load Example

Open up File -> Examples -> Adafruit TSC2007 -> tsc2007_demo and upload to your Arduino wired to the sensor.

#include "Adafruit_TSC2007.h"

Adafruit_TSC2007 touch;

void setup() {
  Serial.begin(115200);
  while (!Serial) delay(10);

  if (!touch.begin()) {
    Serial.println("Couldn't find touch controller");
    while (1) delay(10);
  }
  Serial.println("Found touch controller");
}

void loop() {
  uint16_t x, y, z1, z2;
  if (touch.read_touch(&x, &y, &z1, &z2)) {
    Serial.print("Touch point: (");
    Serial.print(x); Serial.print(", ");
    Serial.print(y); Serial.print(", ");
    Serial.print(z1); Serial.print(" / ");
    Serial.print(z2); Serial.println(")");
  }

  delay(100);
}

Connect a resistive touchscreen to the TSC2007. Upload the sketch to your board and open up the Serial Monitor (Tools -> Serial Monitor) at 115200 baud. You should see the values from the sensor being printed out.

The first number is the X coordinate, the second number is the Y coordinate and the last two numbers are Z "pressure" coordinates that can tell you how hard the touch pad is being pressed

adafruit_products_arduinoSerial.png
arduino serial printout

This guide was first published on Apr 05, 2022. It was last updated on 2022-04-05 19:21:25 -0400.

This page (Arduino) was last updated on May 07, 2022.

Text editor powered by tinymce.