Using MPR121 Sensor to Control LED Tape

Hi,

Prefacing this with: I'm very new to coding, and this could be a mistake in the code or something else entirely.
I'm using an Arduino Uno Rev3 to control an MPR121 Sensor, in hopes that when I touch the sensor, it will turn on LED tape, and when I release it, it will turn off the LED tape. I have used the MPR121 test code, which I have attached, to write my own code controlling the LED Tape through the Arduino. I've changed the code so that not only does it print in the Serial Monitor when I touch or release the sensor, but will also turn on or off the LED Tape in a controlled way. I've defined some of what I'm doing, but not all of it. The formula I'm using to control the LED tape is based off of this tutorial: PWM Exponential LED Fading on Arduino (or other platforms) | Diarmuid.ie

The troubles I'm having are:
The sensor is having difficulties sensing when I've released my electrode, and when I release it, it still does not turn off the LED tape.

#include <Wire.h>
#include "Adafruit_MPR121.h"

// this sets up our LED tape to be using a max brightness of 255, and our fadeSpeed to be 10
#define LED 9
int brightness = 255;
int fadeSpeed = 30;

// The number of Steps between the output being on and off
const int pwmIntervals = 100;

// The R value in the graph equation
float R;

Adafruit_MPR121 cap = Adafruit_MPR121();

// Keeps track of the last pins touched
// so we know when buttons are 'released'
uint16_t lasttouched = 0;
uint16_t currtouched = 0;

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

while (!Serial) { // needed to keep leonardo/micro from starting too fast!
delay(10);
}

Serial.println("Adafruit MPR121 Capacitive Touch sensor test"); 

// Default address is 0x5A, if tied to 3.3V its 0x5B
// If tied to SDA its 0x5C and if SCL then 0x5D
if (!cap.begin(0x5A)) {
Serial.println("MPR121 not found, check wiring?");
while (1);
}
Serial.println("MPR121 found!");

pinMode (LED, OUTPUT);
R = (pwmIntervals * log10(2))/(log10(255));

TurnOn();
TurnOff();
}

// this will set up what our TurnOn () and TurnOff () will do when called upon

void TurnOn() {

for (int interval = 0; interval <= pwmIntervals; interval++) {
// Calculate the required PWM value for this interval step
brightness = pow (2, (interval / R)) - 1;
// Set the LED output to the calculated brightness
analogWrite(LED, brightness);
delay(fadeSpeed);
}
}

void TurnOff() {
for (int i = 0; i < 256; i++) {
analogWrite(LED, brightness);

brightness -= 1;
delay(fadeSpeed);
}

}

void loop() {
// Get the currently touched pads
currtouched = cap.touched();

for (uint8_t i=0; i<12; i++) {
// it if *is* touched and *wasnt* touched before, complete LED turn on
if ((currtouched & _BV(i)) && !(lasttouched & _BV(i)) ) {
Serial.print(i); Serial.println(" touched");
TurnOn();
}
// if it *was* touched and now *isnt*, stop loop
if (!(currtouched & _BV(i)) && (lasttouched & _BV(i)) ) {
Serial.print(i); Serial.println(" released");
TurnOff();
}
}

// reset our state
lasttouched = currtouched;
return;

// debugging info, what
Serial.print("\t\t\t\t\t\t\t\t\t\t\t\t\t 0x"); Serial.println(cap.touched(), HEX);
Serial.print("Filt: ");
for (uint8_t i=0; i<12; i++) {
Serial.print(cap.filteredData(i)); Serial.print("\t");
}
Serial.println();
Serial.print("Base: ");
for (uint8_t i=0; i<12; i++) {
Serial.print(cap.baselineData(i)); Serial.print("\t");
}
Serial.println();


}

DarkCrystal.ino (2.55 KB)

MPR121test.ino (2.35 KB)

The sensor is having difficulties sensing when I've released my electrode, and when I release it, it still does not turn off the LED tape.

What output do you get on the serial monitor in this case?