🍪 Privacy & Transparency

We and our partners use cookies to Store and/or access information on a device. We and our partners use data for Personalised ads and content, ad and content measurement, audience insights and product development. An example of data being processed may be a unique identifier stored in a cookie. Some of our partners may process your data as a part of their legitimate business interest without asking for consent. To view the purposes they believe they have legitimate interest for, or to object to this data processing use the vendor list link below. The consent submitted will only be used for data processing originating from this website. If you would like to change your settings or withdraw consent at any time, the link to do so is in our privacy policy accessible from our home page..

Vendor List | Privacy Policy
Skip to content

Technik Blog

Programmieren | Arduino | ESP32 | MicroPython | Python | Raspberry PI

Menu
  • About me
  • Contact
  • DeutschDeutsch
  • EnglishEnglish
Menu

KS0260 type touch keypad at Arduino

Veröffentlicht am 13. January 20233. May 2023 von Stefan Draeger

In this post, I would like to show you how to program the KS0260 from Keyestudio type touch keypad with 16 buttons on the Arduino.

KS0260 type touch keypad at Arduino
KS0260 type touch keypad at Arduino

The touch keypad comes pre-assembled in a small box, so all you really need is 4 breadboard cables and a microcontroller.

packing KS0260
packing KS0260
packing KS0260 (backsite with QR-Code)
packing KS0260 (backsite with QR-Code)
  • Obtaining the touch keypad
  • Assembly
  • Connection to the microcontroller
  • Connection & Programming
  • Programming
    • Using the library
  • Example

Obtaining the touch keypad

The model I have was purchased on ebay.de for about €4.7 plus shipping costs.

Assembly

The KS0260 touch keypad is connected via I2C, which results in 4 pins that need to be connected to the microcontroller.

Frontside- KS0260
Frontside- KS0260
Backside- KS0260
Backside- KS0260

Connection to the microcontroller

Pins from Touch Keypad KS0260 from Keyestudio
Pins from Touch Keypad KS0260 from Keyestudio

As seen in the above image, the module has an I2C interface, which results in the following connection plan:

KS0260Arduino Microcontroller
3V33.3V
SDAanalog pin A4
SCLanalog pin A5
GNDGND

For this post, I am using the Funduino UNO, which is very similar to the Arduino UNO.

Microcontroller Funduino UNO with Touch Keypad KS0260 from Keyestudio
Microcontroller Funduino UNO with Touch Keypad KS0260 from Keyestudio

Connection & Programming

In the following YouTube video, I will show you how to connect the Keyestudio KS0260 touch keypad to the Funduino UNO and program it.

Keyestudio Touch Keypad KS0260 am Arduino UNO programmieren
Watch this video on YouTube.

Programming

In order to program the KS0260 type touch keypad, we need a library, which can be downloaded from the Ks0260 keyestudio TTP229L 16-key Touch Sensor Wiki page as a RAR file, including an example.

However, since the example provided by the manufacturer generates unnecessary output on the serial interface and the buttons are not described there, I took the time to expand the library.

You can download this library from the link below and install it as a ZIP library in the Arduino IDE (which is not possible with the RAR file).

Touch Keypad KS0260Herunterladen

Using the library

As mentioned earlier, the ZIP file can be imported as a library into the Arduino IDE, and it also contains a small example.

The 16 buttons now have a name and can be accessed through it. To get these names, we just need to initialize the KS0260Button class and then access the constants.

Constants for the keys on the KS0260 module from Keyestudio
Constants for the keys on the KS0260 module from Keyestudio

Now, it is quite easy to check with an if-statement whether the pressed button corresponds to one of the buttons.

data = TTP229_i2c_read();
if (data != 2 && data != 0) {
   String button = "-undefine-";
   switch (data) {
      case btns.button_power:
         button = "Power";
         break;
     }
}

In the code snippet, I have left out the values 2 & 0, as they are alternately output, even if no button is pressed.

Example

Here is the example that I have attached to the ZIP file.

#include "TTP229L_I2C.h"

unsigned int data;

#define debugKs0260 false

KS0260Buttons btns = KS0260Buttons();
btns.button_

void setup() {
  Serial.begin(9600);
}

void loop() {
  data = TTP229_i2c_read();
  if (data != 2 && data != 0) {
    String button = "-undefine-";
    switch (data) {
      case btns.button_power:
        button = "Power";
        break;
      case btns.button_raspberry:
        button = "Raspberry";
        break;
      case btns.button_up:
        button = "Up";
        break;
      case btns.button_down:
        button = "Down";
        break;
      case btns.button_left:
        button = "Left";
        break;
      case btns.button_right:
        button = "Right";
        break;
      case btns.button_home:
        button = "Home";
        break;
      case btns.button_triangle:
        button = "Triangle";
        break;
      case btns.button_quare:
        button = "Quare";
        break;
      case btns.button_circle:
        button = "Circle";
        break;
      case btns.button_cross:
        button = "Cross";
        break;
      case btns.button_l:
        button = "L";
        break;
      case btns.button_minus:
        button = "Minus (-)";
        break;
      case btns.button_plus:
        button = "Plus (+)";
        break;
      case btns.button_r:
        button = "R";
        break;
      default:
        Serial.println("Unknown Code[" + String(data, DEC) + "] found!");
    }
    Serial.println(button);
  }
}

If you upload this code to the microcontroller and press buttons on the touch keypad, the respective text will be output on the serial interface.

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Categories

  • Sponsored Contribution Guidelines

Meta

  • Videothek
  • Impressum
  • Datenschutzerklärung
  • Disclaimer
  • Kontakt
  • Cookie-Richtlinie (EU)

Links

Blogverzeichnis Bloggerei.de Blogverzeichnis TopBlogs.de das Original - Blogverzeichnis | Blog Top Liste Blogverzeichnis trusted-blogs.com
©2023 Technik Blog | Built using WordPress and Responsive Blogily theme by Superb
x
x