Adding Capacitive Touch pins to Teensy 4.0

Status
Not open for further replies.

Davidelvig

Well-known member
I've used the capacitive touch pins on the Teensy 3.2 and 3.6.
I'd like to consider the 4.0.
Any guidance on what cap touch chip to add to my project to fill that gap?
I need at least 4 touch pins connected, and would like to detect touch in about a millisecond per pin.

- Thanks!
 
Posting another plea to get this another view at the top of the list...
I'd love to use the 4.0, but my projects use the 3.x touch pins.

Can anyone recommend an IC add-on to bring Cap Touch to the Teensy 4.0.
 
Why not try the Capacitive Sensor sketch in the Library.
Copy pasted below.......an it works in Teensy 4 as it is gives 3 touch pads.
If more pads needed just add more resistors........and it is very fast

Code:
 #include <CapacitiveSensor.h>

/*
 * CapitiveSense Library Demo Sketch
 * Paul Badger 2008
 * Uses a high value resistor e.g. 10M between send pin and receive pin
 * Resistor effects sensitivity, experiment with values, 50K - 50M. Larger resistor values yield larger sensor values.
 * Receive pin is the sensor pin - try different amounts of foil/metal on this pin
 */


CapacitiveSensor   cs_4_2 = CapacitiveSensor(4,2);        // 10M resistor between pins 4 & 2, pin 2 is sensor pin, add a wire and or foil if desired
CapacitiveSensor   cs_4_6 = CapacitiveSensor(4,6);        // 10M resistor between pins 4 & 6, pin 6 is sensor pin, add a wire and or foil
CapacitiveSensor   cs_4_8 = CapacitiveSensor(4,8);        // 10M resistor between pins 4 & 8, pin 8 is sensor pin, add a wire and or foil

void setup()                    
{
   cs_4_2.set_CS_AutocaL_Millis(0xFFFFFFFF);     // turn off autocalibrate on channel 1 - just as an example
   Serial.begin(9600);
}

void loop()                    
{
    long start = millis();
    long total1 =  cs_4_2.capacitiveSensor(30);
    long total2 =  cs_4_6.capacitiveSensor(30);
    long total3 =  cs_4_8.capacitiveSensor(30);

    Serial.print(millis() - start);        // check on performance in milliseconds
    Serial.print("\t");                    // tab character for debug windown spacing

    Serial.print(total1);                  // print sensor output 1
    Serial.print("\t");
    Serial.print(total2);                  // print sensor output 2
    Serial.print("\t");
    Serial.println(total3);                // print sensor output 3

    delay(10);                             // arbitrary delay to limit data to serial port 
}
 
The Teensy 4 processor does not support touch pins at all, so you can't use the touchRead library. As others have posted, options include using the Capacitive Sensor sensor library or using an offboard processor like the LC. If you are going to use an off board processor via I2C, you may need to figure out whether I2C is fast enough for your needs.

If you are going with off-board solutions, note that Adafruit & Sparkfun have off-board sensors to try out as well:
 
I need at least 4 touch pins connected, and would like to detect touch
Probably means a simple solution to give 4 touch pads.
With the capacitive sensor sketch only 4 resistors are required, it should be easy to test if they are fast enough.
some of the other external boards may have fixed speed of switching...????
 
Yes, FastTouch works on Teensy 4 and very fast, can read all pins within 1 ms ........ and no resistors just pads single wired to the pins
 
Status
Not open for further replies.
Back
Top