Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 9 of 9

Thread: Adding Capacitive Touch pins to Teensy 4.0

  1. #1
    Senior Member Davidelvig's Avatar
    Join Date
    Aug 2015
    Location
    Wisconsin
    Posts
    240

    Adding Capacitive Touch pins to Teensy 4.0

    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!

  2. #2
    Senior Member Davidelvig's Avatar
    Join Date
    Aug 2015
    Location
    Wisconsin
    Posts
    240
    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.

  3. #3
    Senior Member+ Theremingenieur's Avatar
    Join Date
    Feb 2014
    Location
    Colmar, France
    Posts
    2,535
    I’d consider using a Teensy LC as a Touch sub-processor and communicating with the T4.0 over I2C

  4. #4
    Senior Member Davidelvig's Avatar
    Join Date
    Aug 2015
    Location
    Wisconsin
    Posts
    240
    Good idea.
    Thanks

  5. #5
    Senior Member
    Join Date
    Apr 2014
    Posts
    318
    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 
    }

  6. #6
    Senior Member+ MichaelMeissner's Avatar
    Join Date
    Nov 2012
    Location
    Ayer Massachussetts
    Posts
    3,271
    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:

  7. #7
    Senior Member
    Join Date
    Apr 2014
    Posts
    318
    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...????

  8. #8

  9. #9
    Senior Member
    Join Date
    Apr 2014
    Posts
    318
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •