Native Capacitive Touch - Arduino Nano

Hi Everyone

I am playing around with the native capacitive touch function I found here: Arduino Playground - HomePage

I am using an arduino Nano with 8 analogue Inputs. For A6 and A7 the only reading I get is 17. The two pins appear to simply do nothing at all. I guess this might be an issue of the portmanipulation and bit-math which is going on in the function, but its really beyond my programming skills.

Does anyone know what the problem might be and how to fix it?

Thanks

p.

here is my code, though I doubt that is the issue:

void setup() {
  Serial.begin(9600);
}


void loop() {
  
  Serial.print(readCapacitivePin(A0));
  Serial.print(", ");
    Serial.print(readCapacitivePin(A1));
    Serial.print(", ");
    Serial.print(readCapacitivePin(A2));
   Serial.print(", ");
    Serial.print(readCapacitivePin(A3));
  Serial.print(", ");
    Serial.print(readCapacitivePin(A4));
  Serial.print(", ");
    Serial.print(readCapacitivePin(A5));
  Serial.print(", ");
    Serial.print(readCapacitivePin(A6));
  Serial.print(", ");
    Serial.print(readCapacitivePin(A7));
  Serial.println("");
  
  

  delay(1);        // delay in between reads for stability
}

The output on my serial console looks something like this:

2, 2, 1, 2, 2, 1, 17, 17
2, 2, 1, 2, 2, 1, 17, 17
2, 2, 1, 2, 2, 1, 17, 17
2, 2, 1, 2, 2, 1, 17, 17
2, 2, 1, 1, 2, 1, 17, 17
2, 2, 1, 2, 2, 1, 17, 17
2, 2, 1, 1, 2, 1, 17, 17
2, 2, 1, 1, 2, 1, 17, 17
2, 2, 1, 1, 2, 1, 17, 17
2, 2, 1, 1, 2, 1, 17, 17
2, 2, 1, 1, 2, 1, 17, 17
2, 2, 1, 1, 2, 1, 17, 17

If I touch a sensor, it looks like this:

2, 2, 1, 9, 2, 1, 17, 17
2, 2, 1, 9, 2, 1, 17, 17
2, 2, 1, 10, 2, 1, 17, 17
2, 2, 1, 8, 2, 1, 17, 17
2, 2, 1, 9, 2, 1, 17, 17
2, 2, 1, 10, 2, 1, 17, 17
2, 2, 1, 9, 2, 1, 17, 17
2, 2, 1, 6, 2, 1, 17, 17
2, 2, 1, 9, 2, 1, 17, 17
2, 2, 1, 7, 2, 1, 17, 17
2, 2, 1, 9, 2, 1, 17, 17
2, 2, 1, 8, 2, 1, 17, 17
2, 2, 1, 7, 2, 1, 17, 17

pins A6 and A7 r no digital pins, IIRC...
they r just connected to the ADC MUX...

Brunsbuettel... wie schoen :smiley:

Yep - I was afraid of that. I didnt realize those two pins dont work that way until I had all my project soldered and cabled :-S .... if I had known in advance, I would have just used a mega. oh well...

u can use other pins?
or did u already use them all?

wait. they dont need to be analogue pins, do they ... maybe I can :smiley: facepalm

LOL XD