Coder Social home page Coder Social logo

erriez / erriezttp229touchkeypad Goto Github PK

View Code? Open in Web Editor NEW
4.0 2.0 2.0 1.02 MB

TTP229 touch sensitive keypad library for Arduino

Home Page: https://github.com/Erriez/ErriezArduinoLibrariesAndSketches

License: MIT License

C++ 100.00%
erriez touch keypad arduino uno avr atmega328 dual interrupt example documentation getting started ttp229 esp8266 esp32 due

erriezttp229touchkeypad's Introduction

Erriez TTP229 touch sensitive keypad library for Arduino

Build Status

This is an TTP229 touch sensitive library for Arduino.

TTP229

Library features

  • 3.3V and 5V
  • Two wire interface (Not I2C compatible)
  • Single 4x4 touch keypad
  • Dual 4x4 touch keypads
  • Interrupt based
  • UNO/Mini/Micro/Mega2560/Leonardo, ESP8266, ESP32 and DUE

Design notes

  • The PCB must be mounted floated, otherwise key presses don't work reliable.
  • Connect pins 3 and 4 on connector P1 for 16-pin button mode.
  • Smaller keypads with less pins may work, but are not tested.

Examples

Getting started

#include <ErriezTTP229.h>

// TTP229 pin defines
#if defined(ARDUINO_ARCH_AVR)
#define TTP229_SDO_PIN     2  // SDO to interrupt pin 2 (INT0) or pin 3 (INT1)
#define TTP229_SCL_PIN     3  // SCL to any DIGITAL IO pin
#elif defined(ARDUINO_ARCH_ESP8266)
#define TTP229_SDO_PIN    D1  // Interrupt pin
#define TTP229_SCL_PIN    D2  // Any pin
#elif defined(ARDUINO_ARCH_ESP32)
#define TTP229_SDO_PIN     16  // Keep GPIO0 low during programming
#define TTP229_SCL_PIN     4
#else
#error "May work, but not tested on this target"
#endif

// Create keypad object
ErriezTTP229 ttp229;


#if defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32)
ICACHE_RAM_ATTR
#endif
void keyChange()
{
    // A key press changed
    ttp229.keyChange = true;
}

void setup()
{
    // Initialize serial
    Serial.begin(115200);
    while (!Serial) {
        ;
    }
    Serial.begin(115200);
    Serial.println(F("\nErriez TTP229 single 16-keys keypad example"));

    // Initialize keypad with interrupt
    ttp229.begin(TTP229_SCL_PIN, TTP229_SDO_PIN);

    // Initialize interrupt pin on SD0
    attachInterrupt(digitalPinToInterrupt(TTP229_SDO_PIN), keyChange, FALLING);
}

void loop()
{
    // Print key
    if (ttp229.keyChange) {
        Serial.println(ttp229.GetKey16());
        ttp229.keyChange = false;
    }
}

Library dependencies

  • None

Hardware

Arduino UNO
Arduino UNO

ESP8266
Arduino ESP8266

ESP32
Arduino ESP32

DUE
Arduino DUE

Library installation

Please refer to the Wiki page.

Other Arduino Libraries and Sketches from Erriez

erriezttp229touchkeypad's People

Contributors

erriez avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.