0

I'm trying to use the Capacitive Sensing Library by Paul Badger in conjunction with one or more 74HC4067 multiplexers to achieve a lot of capacitive touch inputs. I came across this youtube video where the poster seems to have accomplished what I'm trying but I can't seem to replicate this.

Here is the setup I'm using with an arduino nano, some 1MΩ resistors and a CD74HC4067 breakout :

enter image description here

Here is my Arduino code :

#include <CapacitiveSensor.h>

#define muxS0Pin 7
#define muxS1Pin 6
#define muxS2Pin 5
#define muxS3Pin 4
#define muxSignalPin 3
#define muxEnPin 8
#define capSenseSendPin 2
#define sampleRate 5

int touch[4] = {};

CapacitiveSensor capSense = CapacitiveSensor( capSenseSendPin, muxSignalPin );

void setup() {
    digitalWrite( muxEnPin, LOW );
    Serial.begin( 115200 );
}

void loop(){
    byte touchIndex = 0;
    for ( byte channel = 0; channel < 4; ++channel ) {
        digitalWrite( muxS0Pin, ( channel & 1 ) >> 0 );
        digitalWrite( muxS1Pin, ( channel & 2 ) >> 1 );
        digitalWrite( muxS2Pin, ( channel & 4 ) >> 2 );
        digitalWrite( muxS3Pin, ( channel & 8 ) >> 3 );
        touch[touchIndex] = capSense.capacitiveSensor( sampleRate );
        ++touchIndex;
    }
    for ( byte i = 0; i < 10; ++i ) {
        Serial.print( touch[i] );
        Serial.print("\t");
    }
    Serial.println();
}

This example attempts only four capacitive touch pads but eventually I plan to use all 16 and then another multiplexer, but right now I'm stuck on getting anything, I seem to be getting some readings on touching the last pad but it's not what I expect to see, and it affects all the reading.

I've successfully got a version of this running without a multiplexer just on ten IO pins and it worked great. I also got the multiplexer running fine in a separate example with 16 push buttons.

Could the problem be due to pad charge times or the send-recieve capsense signals getting stopped in the multiplexer?

Any and all help would be appreciated.

  • Here is the link to the library : playground.arduino.cc/Main/CapacitiveSensor – juliusbangert Jul 21 '17 at 16:14
  • And here's a video of my example not working : youtube.com/watch?v=4bGJw1UrgOk. The setup in the video is slightly different than the illustration above; I have pads connected to C6 to C15 on the multiplexer and I loop through them backwards to display them in order on the serial monitor. But the point is, it seems to be only the last multiplexer pin that affects all the readings. – juliusbangert Jul 21 '17 at 17:15
  • Might need to set the mux enable pin (muxEnPin) mode to output in setup(). – Mikael Patel Jul 21 '17 at 20:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.