# Capacitive touch sensor grid to the Arduino?

I am trying to build 8x8 grid that consists of capacitive sensors which we have successfully made by using a high resistors and copper sheets. I used Arduino's library to control it, but my problem is how to control all 64 of them. I have access to almost every kinds of Arduinos in my schools's interaction lab, and since Mega has lots of digital pins that I can use, I have chosen that. However even it has 53 digital pins, and I need to use 10 more pins for other components of my project. I have a multiplexer but sensors I have built and multiplexer do not work together. The problem is, in the library from Arduino, in order to control the capacitive sensor, I need to specify its send and receive pins clearly. If I detach the sensor from on-board pins and attach it to mulplexed pins, it no longer has a PIN number to give to the library. I tried to hack the library, but it was a dead end. Does this means that I cannot use multiplexer and capacitive sensors together, or am I missing something?

Any solution to multiplexing problem or any alternatives that I can use instead of 64 capacitive sensors would be greatly appreciated.

EDIT: I guess I found what I am looking for in Sparkfun Website. According to pin calculations of atmega1280, 2 of these would be sufficient. However I wanna be on the safe side, I will order 3 just in case. I haven't bought and tried it yet, but I believe it can do what I try to do. I'll post results after the shipping.

• Why not scan the matrix instead? – Ignacio Vazquez-Abrams Jan 9 '14 at 1:09
• What do you mean by scanning? – hevele Jan 9 '14 at 1:11

Here's an example of a possible solution using MCP23017 and 4066 switch. In that case you read on 14 and 15. In the example there's two sensor. One attached to U3:A:Y/U3:B:Y and the second one attached to U3:C:Y/U3:D:Y.

You control the MCP23017 with I2C, he will turn on or off the switches and so, select which inputs are connected to pin 14 and 15. One output on the MCP32017 control two switches, one wire pair, so one sensor.

I've only place the "useful" connections and tried to make it as simple as possible. So it's just an idea, not a fully working as-is solution. For example I suggest you to place flip flop with latch to control once the MCP23017 are updated when to reflect the updates on the 4066 and keep them as-is until the next latch or find some 4066 switches with latch.

NOTE : I haven't found touch component in the lib excepted this one... But you get the idea with your two wires for your sensor.

For 64 sensors, you can do it with 32 4066 chips and 4 MCP23017. The pins used on the arduino will be 2 for the sensors and 2 analog to control the 4 MCP23017 through I2C so 4 pins in total, even a UNO or ATTiny can do it.

EDIT

Instead of the 4066 you can use CBT3245A, you'll need 16 of them instead of 32 and they are quite cheap too. Also, another alternative would be to use MAX4618, you'll need 16 of them too, but they are quite expensive. 1.8$each in DIP package on digikey a 4066 is 0.4$ and a CBT3245A in SO package is 0.11$, so 12.8$ in total for 32*4066, 28.8$for 16*MAX4618 and 1.76$ for the 16*CBT3245A (but SO package, can't find DIP)

• Thanks for the detailed explanation how it works. I found another component made by Sparkfun, which makes things a lot simpler. I am still not sure whether it'll work for me, but before I go deeper towards what you have explained, I want to try that. – hevele Jan 9 '14 at 10:24
• I guess I found even cooler solution than my previous comment. I found this, which enables me to control 12 capacitive sensor using one digital and 2 analog pins. – hevele Jan 9 '14 at 11:34