Hi,
I just got myself a TTP229- based 16 button touchpad [datasheet + schematic]. I found a few tutorials online [1] [2] [3] [4] but in all of these tutorials the communication is done "manually" instead of using the I2C library (which the TTP229 supports).
I tried to implement communication via I2C. My code:
#include <Wire.h>
#include <Arduino.h>
//identify code: 1010, device address: 111, read: 1
//10101111 = 0xAF
#define I2C_ADDRESS 0xAF
uint8_t btn_state;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
Wire.begin();
}
void loop() {
// put your main code here, to run repeatedly:
Wire.requestFrom(I2C_ADDRESS, 1, true);
btn_state = Wire.read();
Serial.println(btn_state, BIN);
delay(200);
}
what should happen:
when no button is pressed the Arduino should receive 11111111.
when a button (1 - 8 ) is pressed the Arduino should receive a byte with one bit set to 0, depending on the button pressed (for example: button 1 - 11111110, button 8 - 01111111)
when any of the other buttons is pressed (9 - 16) the Arduino should receive 11111111 (because only buttons 1 - 8 are currently enabled).
what actually happens:
when no button is pressed, the Arduino receives 11111111.
when button 1 is pressed, the Arduino receives 11111110.
when button 3 is pressed, the Arduino receives nothing.
when button 2 or 4 - 8 is pressed, Wire.requestFrom() blocks the code.
when any other button is pressed (9 - 16) the Arduino receives 11111111.
the sketch in link #4 above works as expected (reversed bit order: 1 = 01111111, 8 = 11111110).
can someone help me with this?