0
\$\begingroup\$

I designed a 4x3 keypad using a TTP229-BSF and an ESP32. The board works perfectly when I put 4 mm plastic over the board.

But when I add 2.5 mm of plexiglass over the plastic, some of the keys (3, 6, and 9) become less sensitive than the others and require more pressing while the other keys (1, 2, 4, 5, 7, 8, *, and 0) work perfectly and are enabled with just a touch.

I attached some parts of the schematic. The top picture is the schematic of the power source and the bottom one is the schematic of the TTP229. I also attached my code.

What might be the problem?

enter image description here

enter image description here

#include "Arduino.h"

#define SCL_Pin 16
#define SDO_Pin 27
        
void read_function (void);

int flag=0;
// Touchpad value
uint16_t touchVal=0; // var for ISR access
uint16_t touchValc=0;
// copy var for main loop
IRAM_ATTR void isr() {
  touchVal = 0;
  flag = 1;
}

void setup() {
  Serial.begin(115200);
  Serial.println("salam");
  pinMode(SCL_Pin, OUTPUT);
  pinMode(SDO_Pin, INPUT);

  digitalWrite(SCL_Pin,HIGH);
  // set up INT1 on digital pin 3

  attachInterrupt(digitalPinToInterrupt(SDO_Pin), isr, FALLING);
}
        
void loop() {
  if (flag == 1) {
    //Serial.println("interrupt activated");
    read_function();
  } else if (touchVal) {
    Serial.println(touchVal);
    delay(200);
  }
}
        
void read_function (void) {
  delayMicroseconds(103);
  for (byte i=1; i<=16; i++) {
    digitalWrite(SCL_Pin,LOW);
    delayMicroseconds(70);
    if (!digitalRead(SDO_Pin)) {
      touchVal =i;
    }

    digitalWrite(SCL_Pin,HIGH);

    delayMicroseconds(70);
  }

  flag=0;
}
\$\endgroup\$
1

1 Answer 1

0
\$\begingroup\$

I found what to do to increase the sensitivity of those three keys. I added a 715K resistor to ground from the pin TP5 to make the sampling rate in wake up 64 Hz. and then added another 715k resistor from TP8 to ground. the board works fine now.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.