Sensor Report: Capacitive vs. Resistive Touch Screens

Introduction

Touchscreens are everywhere and fully integrated in our everyday lives. From our smartphones, tablets, and personal computers, to game consoles, ATMs, and POS systems, it’s almost counterintuitive and discombobulating now when we encounter a screen that doesn’t possess touch-enabled functionality. There are many touchscreen technologies with different methods of sensing touch, but the most common of them are either resistive or capacitive. 

How Resistive Touch Screens Work

Resistive touchscreens work on the basis of pressure applied to the screen. They are made up of layers separated by thin air gaps. The top layer is typically a thin, flexible plastic and the lower layer is a firmer plastic or glass. Both layers are coated with electrically conductive and resistive layers and separated by spacer dots. Electric current moves in between the layers. When a finger or stylus applies pressure to the top layer of the screen and the layers are pressed together, it causes a change in current and the touch is registered. The change is then interpreted by a processor that determines the coordinates of where the screen was touched and the assigned function is carried out.

How Capacitive Touch Screens Work

There are three main components to a capacitive touch screen — the touch sensor, the controller, and the software driver. 

The touch screen sensor is a sheet of glass designed with a grid of hair-thin lines of conductive metal such as ITO (indium tin oxide). The grid lines in one direction are called driving lines, which provide a constant electric current. The lines in the other direction are called sensing lines, which detect electric current.

At every point where the sensing lines and driving lines intersect, there is a specific electrostatic field, which is registered as neutral by the controller in the device.

The user is part of the equation that makes the electronics work. The human body has a natural capacitance and can conduct electric current and store electric charge. When the finger touches the screen, the charge in the screen is drawn around that point, distorting the electrostatic field. The electrostatic field feels the effects of the user’s electric charge and redistributes itself accordingly. The controller transmits this information to the software driver, which maps certain patterns such as taps, slides, and multi-touch gestures to perform different functions.

Useful Applications

Besides being a display, touchscreens allow the user to interact and have tangible control over what is displayed. We practically have capacitive touchscreens glued to the palms of our hands in the form of smartphones and tablets. Resistive touchscreens are more commonly used in POS devices and self-checkout kiosks, interactive display systems such as shopping mall information screens, ATM and public transport ticket issuing machines, and gaming devices including the Nintendo DS and 3DS family.

Data Sheets

To compare the two, I referenced the capacitive touchscreen I interact with on a daily basis — my Samsung Galaxy smartphone, as well as the 2.8″ TFT LCD with Touchscreen Breakout Board with MicroSD Socket – IL19341 I purchased from Adafruit for $29.95. Adafruit also sells a 2.8″ TFT LCD with Cap Touch Breakout Board with MicroSD Socket for $39.95.

The technical details for both are as follows:

  • 8 bit digital interface, plus 4 or 5 control lines (12 pins minimum) or SPI mode with 4 or 5 SPI data/control lines (4 pins minimum) – not including the touch screen.
  • 5V compatible! Use with 3.3V or 5V logic such as an Arduino
  • Onboard 3.3V @ 150mA LDO regulator
  • 4 white LED backlight, transistor connected so you can PWM dim the backlight

Resistive Touch Screen | Data Sheet

  • 4 pins are required for the touch screen (2 digital, 2 analog)

Capacitive Touch Screen | Data Sheet

  • 2 I2C pins are required for the touch screen controller

Wiring for Resistive Touchscreen Controller with Arduino 

Data lines: D0 and D1 go to digital #8 and #9, then D2-D7 connect to #2 thru #7.

Control lines: Connect the third pin CS (Chip Select) to Analog 3, fourth pin C/D (Command/Data) to Analog 2, fifth pin WR (Write) to Analog 1, Connect the sixth pin RD (Read) to Analog 0. Optional: Connect the seventh pin to RST to reset the panel.

Code

Download Adafruit’s Touchscreen Library, TFTLCD Library, and GFX Library

*Note: I did not test Adafruit’s capacitive touchscreen, but the wiring and example code can be found here

Application Notes

I plan to use touchscreen as my tangible interface for the DMX lighting controller assignment.

Resistive Strengths & Weaknesses 

Pros: Lower cost, does not require a stylus or object with a capacitive tip to operate, can operate with gloved hands, higher sensor resolution for applications that require registering finer points of contact (ie. small buttons, handwriting), and does not pick up on accidental touches.

Cons: Low sensitivity/requires applied pressure, does not support multi-touch.

Capacitive Strengths & Weaknesses 

Pros: Multi-touch and gesture support, incredibly touch sensitive and responsive, higher image quality.

Cons: Higher cost, gloved hands will interfere with input, and sensitive to inadvertent touches and moisture.

Citations and References

www.slideshare.net/lavinkatiyar/capacitive-touch-screen
www.goodgearguide.com.au/article/355922/capacitive_vs_resistive_touchscreens
www.electronicdesign.com/displays/what-s-difference-between-resistive-and-capacitive-touchscreens
www.embeddedarm.com/blog/reach-out-and-touch-something-capacitive-vs-resistive-touch-screens
www.youtube.com/watch?v=wKuqNuzM1oM

MIDI Controller – hAir Orchestra

This week’s assignment is to make a music playback controller using MIDI. Seeing all the NIME performances last year intrigued me, so I want to be more open to experimentation and think outside of the box and buttons. I have very long wavy hair and my fingers are constantly running through it to untangle all the knots so naturally, I decided I wanted to play my hair as a musical instrument. Initially I wanted to experiment with an electrostatic generator so my hair becomes conductive and can stick up in all directions as I play, but that was quickly shot down before I could work out the logistics after an office hour session with Tom (given the two week deadline and mostly because it’s potentially dangerous). After speaking to Tom, I decided my best option is to use conductive thread to simulate hair. On the last game controller assignment, I regretted not getting the MPR121 breakout board for my capacitive touch arrow keys, so I decided to get it for this assignment to map 12 strands of “hair” to 12 notes.

Lauren and I decided to collaborate on this project together. On Thursday night, we got together to look at the class notes and wire the circuit for MIDI output on our Arduino UNO. After we got it working via USB MIDISPORT2x2 and GarageBand, we played with some of Aaron Montoya’s personal drum and bass synths, and the Yamaha tone generator that had some nice string options with vibrato and pizzicato. Over the next three days, I poured over documentation and instructables on MPR121 and MIDI. I referenced Adafruit’s example code to understand how the capacitive touch sensor works and adapted the logic of Tom’s 4-key Piano Controller to generate sound. I am slowly learning how to understand and reformulate existing code to get it to do what I want, but I definitely want to get to a point where I can write my own code from scratch.

 

Since we wanted to keep our board set up compact enough to possibly fit in a headpiece, Lauren suggested we use the MKRZERO, which is a board recommended on the Arduino website for sound, music, and digital audio data. We spent the weekend debugging, troubleshooting, and failing to generate sound with the set up below:

The screen on the Yamaha tone generator kept reading: Err IlglData. Our classmate Elizabeth also ran into the same issue, but she was able to get some sound with delay. In retrospect, I’m sure there were mistakes I didn’t catch, but eventually we went back to what we know worked:

Code:

This is our first prototype in action. The challenge now resides in that the “hairs” keep touching each other so there is less control and distinction of individual notes. I would like to resolve this for a future iteration.

References:

https://github.com/tigoe/ArduinoGeneralExamples/blob/master/M0MidiController/M0MidiController.ino

https://learn.sparkfun.com/tutorials/mpr121-hookup-guide

http://gordophone.blogspot.com/2016/04/aside-touch-sensing-with-mpr121.html

http://www.instructables.com/id/Easy-DIY-Arduino-Touch-Sensor-Mini-Piano/

Special thanks to Tom Igoe, Tiri Kananuruk, Sebastian Morales, Jim Schmitz, Aaron Montoya-Moraga, and Aaron Parsekian!

Game Controller – Lunar Lander

This week’s assignment is to make a game controller for Lunar Lander. My goal was to use materials I have on hand and not spend additional money. The scraps of conductive fabric in my toolbox reminded me of capacitive touch sensing and a project previous ITP students worked on called the Gesture-Sensing Tek-Tile:

I had the pleasure of talking to Renata last semester about it and she explained that it uses capacitive touch sensing with a break-out board that you can buy on Adafruit. I did some research and found that it can be done digitally (albeit less conveniently) by connecting each sensor to 2 pins, send and receive. The send pin, which can be shared by multiple sensors, must connect with a large-value resistor between 100K to 50M (I used 100K). I modified the Capacitive Sensor library example code below and was surprised to see ten digit values shoot up to 800+ with light taps.

When I transferred my set up from Arduino Uno over to Adafruit’s Feather M0, I was not able to receive data from any of my sensors. I then troubleshooted with an Arduino MKR1000 from the shop and it worked perfectly. The only difference I can discern is the feather can only supply up to 3.3V, which I’m assuming is the issue…

  

Code (I referenced a capacitive sensor Arduino piano instructable by Tyler Crumpton) :

#include <Keyboard.h>
#include <CapacitiveSensor.h>

#define COMMON_PIN 4 // The common ‘send’ pin for all keys
#define NUM_OF_SAMPLES 30 // Higher number when more delay but more consistent readings
#define CAP_THRESHOLD 800 // Capacitive reading that triggers keys
//#define NUM_OF_KEYS 4 // Number of keys that are on the keyboard

// This macro creates a capacitance “key” sensor object for each key on the game controller:
#define CS(Y) CapacitiveSensor(4, Y)

// Click to start game:
int mouse = MOUSE_RIGHT;
// Define pin connected to mouse:
CapacitiveSensor mouseSensor = CS(3) ;
// Each key corresponds to an arrow:
int keys[]={KEY_UP_ARROW, KEY_LEFT_ARROW, KEY_RIGHT_ARROW};
// Defines the pins that the keys are connected to:
CapacitiveSensor pins[] = {CS(2), CS(1), CS(5)};

void setup() {
// Turn off autocalibrate on all channels:
for(int i=0; i<4; ++i) {
pins[i].set_CS_AutocaL_Millis(5000);
}
Serial.begin(9600);

}

void loop() {
// // If the capacitance reading is greater than the threshold, mouse click to start game:
if(mouseSensor.capacitiveSensor(NUM_OF_SAMPLES) > CAP_THRESHOLD) {
Mouse.click();
delay(100);
Mouse.release();
}

// Loop through each key:
for (int i = 0; i < 4; ++i) {
// If the capacitance reading is greater than the threshold, press corresponding keys:
if(pins[i].capacitiveSensor(NUM_OF_SAMPLES) > CAP_THRESHOLD) {
Keyboard.press(keys[i]);
delay(100);
Keyboard.release(keys[i]);
}
}
}

For the enclosure, I used a small cardboard box I found on the shop floor by the junk shelf and managed to fit everything inside:

For the controller pad, I designed an intuitive fingerboard similar to how we position our fingers when using the arrow keys. To start the game, the user simply moves their index finger over to tap the start button. I also downloaded the font from the game and used motifs like the landing point system to complement the game:

The cut-out fingers are backed with conductive fabric and foam for a more satisfying touch sensation:

References:

https://playground.arduino.cc/Main/CapacitiveSensor?from=Main.CapSense

https://www.arduino.cc/en/Tutorial/KeyboardAndMouseControl

https://www.pjrc.com/teensy/td_libs_CapacitiveSensor.html

https://learn.adafruit.com/plush-game-controller/the-code

http://www.instructables.com/id/Capacitive-Touch-Arduino-Keyboard-Piano/