Re: Keypad for Raduino...?

Arv Evans
 

Jerry

Thanks for the info.  I did a quick scan of the relevant pages. I can see several possible
uses for this device.  Maybe I missed something but it seems that  like almost all I2C
devices it is a true slave and thus does not automatically assert bus control to signal that
an event has occurred.  Possibly I would need to re-read the datasheet in detail to affirm
this if my design effort takes me in that direction.

Arv
_._


On Mon, Jun 25, 2018 at 10:05 AM Jerry Gaffke via Groups.Io <jgaffke=yahoo.com@groups.io> wrote:
Here's a datasheet  (sort of, you don't get the pdf):  https://pdf1.alldatasheet.com/datasheet-pdf/view/810501/TONTEK/TTP229.html
Bottom of page 8, section 3-4 describes the 2 wire interface, though not very clearly.

They say SDO is always out, SCLK is always in.
And that SCLK can be anything between 1khz and 512khz when scanning.
A pause of 2ms on SCLK resets the interface for the next scan.
They apparently have a way to just check the state of SDO occasionally to see if any key was pressed,
though I find the datasheet tough to read on exactly how this works.

The chip also implements full i2c mode, also various parallel modes,
though not clear what modes any particular keypad using the chip would support.

Jerry


On Mon, Jun 25, 2018 at 08:38 am, Robert McClements wrote:
Arv,

The TTP229 capacitive  keyboard has two pins labelled SCL and SDO but unfortunately they are not I2C.

The way that they work is SCL is clocked frequently up to 16 times and during each clock cycle SDO is
checked. If a key is pressed SDO will return a Low, the count stops and the clock count equates to
the key number. Hope that makes sense, not easy to put into words.

So this device will require the use of two digital pins.


Regards,

Bob GM4CID

Sample code below :-

 // Routine to read if a key is pressed and return its value
byte Read_Keypad(void)
{
   byte Count;
   byte  Key_State = 0;
   for(Count = 1; Count <= 16; Count++) // Pulse the clock pin up to 16 times and read the state of the data pin on each pulse
   {
      digitalWrite(Clock_PIN, LOW);
      if  (! digitalRead (Data_PIN)) // data pin low store the current key number
         Key_State = Count;
      digitalWrite(Clock_PIN, HIGH);
   }
   return Key_State;

Join BITX20@groups.io to automatically receive all group messages.