adafruit / Adafruit_CircuitPlayground

library for Circuit Playground board
171 stars 77 forks source link

Capacitive touch not working on Bluefruit Playground #49

Closed amiika closed 4 years ago

amiika commented 4 years ago

It seems that capacitive touch is now working on CPB. For example this doesnt read anything:

CircuitPlayground.readCap(0)

Pinning seems to be different because some caps work, for example A6 = 0, A7 = 1 ... etc.

ladyada commented 4 years ago

please update all board support packages & libraries and compile/run the 'demo' example - paste the output here :)

amiika commented 4 years ago

Thanks! I see my issue now. I thought that those caps were from 0-7 and tried something like:

void loop() {
  for(int i=0;i<7;i++) {
    float val = CircuitPlayground.readCap(i);
    if(val>250) {
      Serial.print("Touched: "); Serial.println(i);
      delay(100);
    }
  }
 }

Didn't realize the cap numbers were so odd, but looked at the demo got it working:

void loop() {
  CircuitPlayground.speaker.enable(false);
  int caps[] = {6,9,10,3,2,0,1};
  for(int i=0;i<7;i++) {
    float val = CircuitPlayground.readCap(caps[i]);
    if(val>500) {
      Serial.print("Touched: A"); Serial.print(i+1); Serial.print("  Val: "); Serial.println(val);
      delay(100);
    }
  }
 }

Thanks again. You are the best! :)