Re: Keypad for Raduino...?

Mike Woods
 

This is not quite correct.  This sketch is a hack that would work but the TTP229 is a true i2c device.  See the following use case that deploys the wire library:


This is an easy add to the uBITx for somebody wanting a keypad ... but why not use a Nextion display with KD8CEC firmware?  It already has firmware built to provide touchpad frequency entry in the UI!

It is a bit the same as building an analogue S-meter when KD8CEC firmware and Nextion already feature a classy digital S-meter that can be calibrated easily...

There are always different ways of doing things, but some ways are easier than others!

Mike ZL1AXG

Mike

On Tue, 26 Jun 2018 at 3:38 AM, Robert McClements <gm4cid@...> 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.