Hello guys,
I have an MPR121 board that I use to detect touch. It works fine on the Arduino Uno. However, when I connect it to the Arduino Due it does not seem to work. It keeps saying that there is a readback error (readback failure) while with the Arduino Uno everything works fine.
The pins are attached to:
VIN to 3.3V Due
GND to GND of Due
SDA to SDA(20) of Due
SCL to SCL(21 of Due
IRQ to Pin4
I hope you can help me a bit further since I cannot understand why the sketch is working on the Arduino Uno Board while the same sketch is not working on the Arduino Due board and gives an error message back on the Serial Monitor.
#include <MPR121.h>
#include <Wire.h>
#define numElectrodes 12
void setup()
{
Serial.begin(9600);
while(!Serial); // only needed if you want serial feedback with the
// Arduino Leonardo or Bare Touch Board
Wire.begin();
// 0x5C is the MPR121 I2C address on the Bare Touch Board
if(!MPR121.begin(0x5A)){
Serial.println("error setting up MPR121");
switch(MPR121.getError()){
case NO_ERROR:
Serial.println("no error");
break;
case ADDRESS_UNKNOWN:
Serial.println("incorrect address");
break;
case READBACK_FAIL:
Serial.println("readback failure");
break;
case OVERCURRENT_FLAG:
Serial.println("overcurrent on REXT pin");
break;
case OUT_OF_RANGE:
Serial.println("electrode out of range");
break;
case NOT_INITED:
Serial.println("not initialised");
break;
default:
Serial.println("unknown error");
break;
}
while(1);
}
// pin 4 is the MPR121 interrupt on the Bare Touch Board
MPR121.setInterruptPin(4);
// this is the touch threshold - setting it low makes it more like a proximity trigger
// default value is 40 for touch
MPR121.setTouchThreshold(40);
// this is the release threshold - must ALWAYS be smaller than the touch threshold
// default value is 20 for touch
MPR121.setReleaseThreshold(20);
// initial data update
MPR121.updateTouchData();
}
void loop()
{
if(MPR121.touchStatusChanged()){
MPR121.updateTouchData();
for(int i=0; i<numElectrodes; i++){
if(MPR121.isNewTouch(i)){
Serial.print("electrode ");
Serial.print(i, DEC);
Serial.println(" was just touched");
} else if(MPR121.isNewRelease(i)){
Serial.print("electrode ");
Serial.print(i, DEC);
Serial.println(" was just released");
}
}
}
}