To be more specific I have three (code below is for two sets) strips of conductive fabric for which I want to detect a stroking rate, which then activates a vibrating disc. With the usb I only have to touch one strip for the presses to be detected, but with just the battery I have to touch two strips at the same time.
Why should the battery/usb make a difference?
Here's some code:
Code: Select all
boolean currentPressed[ ] = {false, false, false, false, false, false};
#define THRESH 0
... loop code
for (int i=0;i<6;i++) {
long total = pins[i].readPin(400);
if ((total > THRESH) && (!currentPressed[i])) {
currentPressed[i] = true;
lastpress = millis();
numPressed ++;
strokingRate += 2;
}
else if ((total <= THRESH) && (currentPressed[i])) {
currentPressed[i] = false;
numPressed --;
}
if (currentPressed[i]) {
if (numPressed > 0)
total = (int) (total / numPressed);
if (total > 128) total = 128;
}
}