Capacitive Touch with Teensy 4.x

Davidelvig

Well-known member
I’m using all 12 cap touch pins on my Teensy 3.2 product. Except for the lack of cap touch pins on the Teensy 4, I’d love to upgrade to it.

Does anyone have experience using a particular cap touch chip that provides similar performance to those in the ARM chip of Teensy 3.2?

With the 3.2 , I can sample a “touched” value on a pin in about 1/3 millisecond
(I tweaked the cap touch library a bit to bail early when it’s charged “enough”)
 
I see you asked about this a couple of years ago, and were told about fastTouch then. So I wrote a little benchmark to see how fast it really was. I have a box with 12 fastTouch pins and a T4.

Here's the code:
Code:
#include <FastTouch.h>

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
}
//{29,14,16,32,28,27,25,31,2,3,9,33}
void loop() {
  // put your main code here, to run repeatedly:
long preMicros=micros();
 if (fastTouchRead(29) >30) {Serial.println("29");}
 if (fastTouchRead(14) >30) {Serial.println("14");}
 if (fastTouchRead(16) >30) {Serial.println("16");}
 if (fastTouchRead(32) >30) {Serial.println("32");}
 if (fastTouchRead(28) >30) {Serial.println("28");}
 if (fastTouchRead(27) >30) {Serial.println("27");}
 if (fastTouchRead(25) >30) {Serial.println("25");}
 if (fastTouchRead(31) >30) {Serial.println("31");}
 if (fastTouchRead(2) >30) {Serial.println("2");}
 if (fastTouchRead(3) >30) {Serial.println("3");}
 if (fastTouchRead(9) >30) {Serial.println("9");}
 if (fastTouchRead(33) >30) {Serial.println("33");}
 long endMicros= micros();
 Serial.print("fastTouch x 12 took ");
 Serial.print(endMicros-preMicros);
 Serial.print("microSec    or ");
 Serial.print((endMicros-preMicros)/12);
 Serial.println(" per pin.");
}

Here's the output:
fastTouch x 12 took 21microSec or 1 per pin.
9
fastTouch x 12 took 21microSec or 1 per pin.
9
fastTouch x 12 took 21microSec or 1 per pin.
9
fastTouch x 12 took 21microSec or 1 per pin.
9
fastTouch x 12 took 21microSec or 1 per pin.
9
fastTouch x 12 took 20microSec or 1 per pin.
9
fastTouch x 12 took 21microSec or 1 per pin.

It seems like fastTouch on the T4 is fast enough.
 
Finally have a Teensy 4.1, and plan to use it... now that I've demonstrated your library working BEAUTIFULLY!

Thanks, @jrraines!
 
Back
Top