Is this a known incompatibility?
Using teensy 3.6 and audio board, trying to set up cap sensing and get some delay and audio as well.
Wrote a simple program to calibrate each pin and then report if they're touched. However, I'm unable to time it with elapsedmillis. Pretty sure it is down to the touchread as when I comment out:
it works nicely. When touchread loops are left in, it just returns 1 or 0.
Thanks for your help.
Using teensy 3.6 and audio board, trying to set up cap sensing and get some delay and audio as well.
Wrote a simple program to calibrate each pin and then report if they're touched. However, I'm unable to time it with elapsedmillis. Pretty sure it is down to the touchread as when I comment out:
Code:
for (int i = 0; i < actualnoofpins; i++) {
bigarray[3][i] = touchRead(bigarray[0][i]); //logs touchread value in 3rd row
if (bigarray[3][i] > bigarray[2][i]) { //if touchread of pin bigger than fudged average
bigarray[4][i] = 1;
}
else {
bigarray[4][i] = 0;
}
}
it works nicely. When touchread loops are left in, it just returns 1 or 0.
Thanks for your help.
Code:
#include <elapsedMillis.h>
elapsedMillis totaltime;
elapsedMillis startMillis;
int thresholdcap = 51;
float fudgefactor = 1.3;
int bigarray[4][8];
int pinvals[8] = {0, 1, 29, 30, 16, 17, 0, 0}; //LA,B,C,D,E,F - NOTE need to change 0's at end..
const int actualnoofpins = 6;
#define SerialDebug //JUST comment out to remove serial monitor
void setup() {
// put your setup code here, to run once:
#ifdef SerialDebug
Serial.begin(9600);
while ( !Serial && ( millis() - startMillis < 10000 ) );
Serial.println("run ok up to here");
#endif
for (int i = 0; i < 8; i++) { //drops pinvals into bigarray
bigarray[0][i] = pinvals[i];
}
for (int i = 0; i < 20; i++) { //Sums 20 touchreads on each pin
for (int j = 0; j < actualnoofpins; j++) {
bigarray[1][j] = touchRead(bigarray[0][j]) + bigarray[1][j];
}
}
for (int j = 0; j < actualnoofpins; j++) { //Averages pin values then multiplies by fudge
bigarray[2][j] = int(bigarray[1][j] * fudgefactor / 20);
}
#ifdef SerialDebug
Serial.print("Pin calibration values are: ");
for (int i = 0; i < actualnoofpins; i++) {
Serial.print(bigarray[2][i]);
Serial.print(" ");
}
#endif
}
void loop() {
for (int i = 0; i < actualnoofpins; i++) {
bigarray[3][i] = touchRead(bigarray[0][i]); //logs touchread value in 3rd row
if (bigarray[3][i] > bigarray[2][i]) { //if touchread of pin bigger than fudged average
bigarray[4][i] = 1;
}
else {
bigarray[4][i] = 0;
}
}
#ifdef SerialDebug
Serial.print("Pin playing values are: ");
for (int i = 0; i < actualnoofpins; i++) {
Serial.print(bigarray[3][i]);
Serial.print(" ");
}
Serial.print("time between loop is: ");
Serial.println(startMillis);
#endif
}