Advertisement
microrobotics

TTP229 Keypad Code Samples

Aug 25th, 2017
5,591
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.42 KB | None | 0 0
  1. /*********************************** CIRCUIT **********************************\
  2. | 16 Buttons Mode:                                                             |
  3. |   * TTP229 VCC to pin VCC                                                    |
  4. |   * TTP229 GND to pin GND                                                    |
  5. |   * TTP229 SCL to pin 2                                                      |
  6. |   * TTP229 SDO to pin 3                                                      |
  7. |   * TTP229 TP2 to GND via 1 Megohm resistor!                                 |
  8. |                                                                              |
  9. | Important:                                                                   |
  10. |   * Must reconnect the TTP229 power so the mode changes will take effect     |
  11. |   * The 1 Megohm resistors already exist on some TTP229 modules              |
  12. \******************************************************************************/
  13. #include <TTP229.h>
  14.  
  15. const int SCL_PIN = 2;  // The pin number of the clock pin.
  16. const int SDO_PIN = 3;  // The pin number of the data pin.
  17.  
  18. TTP229 ttp229(SCL_PIN, SDO_PIN); // TTP229(sclPin, sdoPin)
  19.  
  20. void setup()
  21. {
  22.     Serial.begin(115200);
  23.     Serial.println("Start Touching One Key At a Time!");
  24. }
  25.  
  26. void loop()
  27. {
  28.     uint8_t key = ttp229.ReadKey16(); // Blocking
  29.     if (key) Serial.println(key);
  30.  
  31. //  uint8_t key = ttp229.GetKey16(); // Non Blocking
  32. //  Serial.println(key);
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement