Hi all,
In the interest of your time, I'll keep this brief.
Equipment: Arduino Mega, MPR121 (Overview | Adafruit MPR121 12-Key Capacitive Touch Sensor Breakout Tutorial | Adafruit Learning System)
Code:
#include <Wire.h>
#include "Adafruit_MPR121.h"
Adafruit_MPR121 cap = Adafruit_MPR121 ();
volatile bool f0 = 0;
volatile bool f1 = 0;
volatile int touchStatus;
void ISR_touch () {
f0 = 1;
touchStatus = cap.touched ();
}
void setup () {
pinMode (18, INPUT_PULLUP);
attachInterrupt (digitalPinToInterrupt (18), ISR_touch, LOW);
Serial.begin (9600);
cap.begin (0x5A);
}
void loop () {
if (f0 == 1) {
f0 = 0;
if (touchStatus == 1){
Serial.println ("1 touched");
} else if (touchStatus == 0) {
Serial.println ("1 released");
}
}
}
Expected outcome:
When I touch the first electrode of the touch IC breakout, I'd get a serial message that that pin has been touched. When I release it, I'd get a serial message that that pin has been released.
Actual outcome:
Nothing happens when I touch electrode 1 of the touch IC breakout.
Thank you.