Need some help with a touchpad

KPollock

Member
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.
 
See this example installed with TeensDuino: {local install}\hardware\teensy\avr\libraries\CapacitiveSensor\examples\CapacitiveSensorSketch\CapacitiveSensorSketch.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 
}
 
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
 
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/Cirq...kpad/Single_Pad_Sample_Code/SPI_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.
 
Back
Top