Go Down

Topic: 20-30 digital buttons on one board (Read 4628 times) previous topic - next topic

C-F-K

Thanks very much!
Sure, I agree that it's fun to figure out things by your self, but it can be also very frustrating :)
I will try the code as soon as I will manage to solder this tiny chip.
I have read tca8418 datasheet serveral times, so now I can see how it translates to the code.
Without your example, I know I would just write something like:

data = 0x81;
Wire.write(data);

instead of:
Wire.write(0xFF & data);
Wire.write(data >> 8);

Why do I need to perform & operation with 0xFF if the result is "data" anyway?
And why do I need to send "data" shifted by eight bits?

Thanks.


The chip expects 2 bytes of data.


As i said, I just started coding when I wrote that... 
Data can have values that are 2 bytes. So when you send the first one, saying (0xFF & data) would send the first byte, and (data >> 8) would send the second. 
It's the same as using highByte() and lowByte().
Evil Base of Operations: Holland

voki


C-F-K

Evil Base of Operations: Holland

voki

Yes, it works! It's without keypad and interrupt yet, I am to tired to solder buttons right now.
At the beginning I2C scanner was able to find device at 0x34, but I could not write or read registers.
It turned out that SCL and SDA 4.7k pullups were needed.
I thought that with such a short lines and only one I2C device, internal pullups will be enough...
I was affraid about hardware as this was my first ever QFN chip soldering, so tiny...
Thank's once again!

MistrKernnunos

Hi, I am trying to use this chip, but I have problem. I managed to set the chip up, but whenever I press a button from key matrix the chip stops answering

Go Up