TTP229 16 Key Capacitive Touch Keypad (TTP229) [S153]




https://www.youtube.com/watch?v=NXZR0p-kX1A


*GitHubhttps://github.com/rdiot/rdiot-s153.git


* Specs

Operating voltage:2.4V~5.5V

Built-in regulator

Stand-by current At 3V, and sleep mode slow sampling rate 8Hz:

=> Typical 2.5uA for 16 input keys

=> Typical 2.0uA for 8 input keys

8 Key or 16 key modes

Separate outputs to 8 keys in 8 key mode

2 wires serial output interface for both 16 key and 8 key mode

Outputs can be set to CMOS/OD/OC with active high/low

2 Wires serial interface can select active high or low by option

Optional Multi-key or single-key

Provides two kinds of sampling rate: slow sampling rate 8Hz and fast sampling rate 64Hz at sleep mode

Optional maximum key-on time about 80sec

Auto calibration at power up (keypad must not be touched for 0.5 seconds after power up)

Auto calibration for changes in environment

 

1.....VCC (2.4 - 5.5V)

2.....GND

3.....SCL (serial clock in)

4.....SDO (serial data out)

5.....OUT 1 (key 1 state)

6.....OUT 2 (key 2 state)

7.....OUT 3 (key 3 state)

8.....OUT 4 (key 4 state)

9.....OUT 5 (key 5 state)

10...OUT 6 (key 6 state)

11...OUT 7 (key 7 state)

12...OUT 8 (key 8 state)


* Contents

- Connect

VCC ----- 5V

GND ----- GND

SCL -----> D2 

SDO -----> D3 


- Key Code

#define pulse 2

#define data 3


int old  = 0;


void setup()

{

  Serial.begin(9600);

  pinMode(pulse, OUTPUT);  

  pinMode(data, INPUT); 

}


void loop()

{

  int Key = getkey();

  

  if (Key!=0&Key!=old)

  {

    Serial.print("PUSH--->");

    Serial.println(Key);


  }

    

  old = Key;

}



byte getkey(void)

{

  byte cnt;

  byte num = 0;

  for(cnt = 1; cnt < 17; cnt++)

  {

    digitalWrite(pulse, LOW); 

    

    if (digitalRead(data) == 0)

      num = cnt; 

    

    digitalWrite(pulse, HIGH);

  }  

  

  return num; 

}

Posted by RDIoT
|