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

Thread: Need some help with a touchpad

  1. #1
    Junior Member
    Join Date
    Jun 2020
    Location
    Canada
    Posts
    5

    Need some help with a touchpad

    Hello everyone, hope you're all doing well.

    I'm trying to learn about using touch pins on a teensy 3.2. I'm looking everywhere and not finding what I'm looking for. I'm finding MIDI stuff, and single press capacitive sensor stuff. Is there a tutorial here or anywhere that shows me how to take the data I'm looking at in the serial monitor and output the values.

    I just want X/Y values to be up, down, left, right. I don't mind reading and learning. I've dug myself deep into a hole, and I want to learn my way out (hopefully).

    Have a great day everyone.

  2. #2
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    16,519
    See this example installed with TeensDuino: {local install}\hardware\teensy\avr\libraries\CapacitiveS ensor\examples\CapacitiveSensorSketch\CapacitiveSe nsorSketch.pde

    It shows some details on configuration and provides example code that may answer your questions:
    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 
    }

  3. #3
    you said specifically the teensy3.2 which supports touch in hardware, like this:
    Code:
    #define WHITETOUCH  32       //touchpads -- color wire attached to pad/pin #
    #define PURPLETOUCH  1
    #define GRAYTOUCH   22
    #define BLUETOUCH   33      //on the back side
    #define YELLOWTOUCH 17
    #define GREENTOUCH  16 
    #define ORANGETOUCH  0
    #define BROWNTOUCH  23
    #define TOUCHTHRESHHOLD 1400
    .....
      if (touchRead(WHITETOUCH) >TOUCHTHRESHHOLD) { 
        hADD++; Serial.println("hour button"); delay(200);} 
         
      if (touchRead(GRAYTOUCH) >TOUCHTHRESHHOLD){
        mADD++; Serial.println("minute button"); delay(200);}
        
      if (touchRead(BLUETOUCH)  > TOUCHTHRESHHOLD) { state = 1; Serial.println("Touched Blue"); }
      if (touchRead(YELLOWTOUCH)  > TOUCHTHRESHHOLD) { state = 3; Serial.println("Touched Yellow"); }
      if (touchRead(PURPLETOUCH)  > TOUCHTHRESHHOLD) { state = 2; Serial.println("Touched Purple");}
      
      if (touchRead(ORANGETOUCH)  > TOUCHTHRESHHOLD) { state = 4; Serial.println("Touched ORANGE");}
      
      if (touchRead(GREENTOUCH)  > TOUCHTHRESHHOLD) { state = 5;Serial.println("Touched Green"); }
      if (touchRead(BROWNTOUCH)  > TOUCHTHRESHHOLD) { state = 6;Serial.println("Touched Brown"); }
    no resistors needed

  4. #4
    Junior Member
    Join Date
    Jun 2020
    Location
    Canada
    Posts
    5
    I think (don't hold me to that lol) I'm understanding better.

    Been trying to write a reply since you posted. So I'm attaching the link to the github. This may make it easier.
    https://github.com/cirque-corp/Cirqu..._CurvedOverlay

    The code is all there. But because it's not using CapacitiveSensor.h and using SPI.h, this is where I've become lost. I just want to use the pinnacle values as a joystick or directional pad if that's even possible...

    I've went to the library and picked up a C+ book to learn and read. So my adventure is still on going haha.

  5. #5
    Junior Member
    Join Date
    Jun 2020
    Location
    Canada
    Posts
    5
    I think I found exactly what has been troubling me. In this old forum from long ago (link below). Curious has any update been done with this? Can I read and learn more about it/ where?

    My project uses:
    pin 14 as X-position low
    pin 15 as Y-position low
    pin 16 as X & Y high
    pin 17 as z level

    https://forum.pjrc.com/threads/59307...-Teensy-boards

Posting Permissions

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