Hi there,
I'm trying to run an Adafruit MPR121 Capacitive Touch sensor on a new Arduino Due along with a Adafruit PN532 NFC Shield, WINC1500 WiFi shield and a strange non-stackable pressure map matrix shield.
Everything is working except the MPR121 which we cannot get to work on the Due whatsoever - with or without the other components. I've seen few people in 2015 have this problem but have not found an answer.
An Adafruit forum post (https://forums.adafruit.com/viewtopic.php?f=19&t=68139) suggested to define _BV which we have tried but to no avail.
They symptom is that whenever the MPR121 enters a function, such as cap.begin() or cap.touched() the program hangs. (As you can see in the screenshot - even when cap.begin() is deleted cap.touched() will still cause a hang.)
The MPR121 has tested find on a Mega2560, I've checked the soldering, tried different SCL/SDA pins. If anyone has any ideas around what I could do or what I could test next it would be great.
I'll upload a photo of the setup (excuse the wiring, it's hectic due to the pressure matrix) along with the basic code I've been using to test with.
#include <Adafruit_MPR121.h>
#include <Wire.h>
#include "TimeLib.h"
#include "time.h"
#ifndef _BV
#define _BV(bit) (1<<(bit))
#endif
Adafruit_MPR121 cap = Adafruit_MPR121();
uint16_t lasttouched = 0;
uint16_t currtouched = 0;
unsigned long time;
String left;
String right;
int l = 0;
int r = 0;
int finalise = 0;
void setup() {
Serial.begin(9600);
while (!Serial) {
delay(100);
}
Serial.println("Adafruit MPR121 Capacitive Touch sensor test");
if (!cap.begin(0x5A)) {
Serial.println("MPR121 not found, check wiring?");
while (1);
}
Serial.println("MPR121 found!");
}
void loop() {
delay(100);
time = millis();
currtouched = cap.touched();
for (uint8_t i=0; i<12; i++) {
if ((currtouched & _BV(i)) && !(lasttouched & _BV(i))) {
Serial.print(i); Serial.print(" touched at "); Serial.println(time);
if (i == 5){
left = left + " " + time;
l++;
}
else if (i == 7){
right = right + " " + time;
r++;
}
}
if (!(currtouched & _BV(i)) && (lasttouched & _BV(i))) {
Serial.print(i); Serial.print(" released at "); Serial.println(time);
if (i == 5){
left = left + " " + time;
l++;
}
else if (i == 7){
right = right + " " + time;
r++;
}
}
if(time > 60000 && finalise == 0){
Serial.println(left);
Serial.println(right);
finalise++;
delay(60000);
}
}
lasttouched = currtouched;
}
Thanks!

