Hi Robert, thanks for your advices.
I managed to make it work only for a few minutes on one sample, but after power off (lunch pause) and on, not working again on any sample.
But I really think that for some reason the prescale value is not set or gets corrupted if I put it in the setup part. Therefore I managed to solve it by doing the setting the first time it enters the loop part:
void setup() {
slider.setup(sliderPads, NUM_TOTAL_PADS);
// Initialise serial and touch sensor
Serial.begin(115200);
while(trillSensor.setup(Trill::TRILL_FLEX)) {
Serial.println("failed to initialise trillSensor");
Serial.println("Retrying...");
delay(100);
}
Serial.println("Success initialising trillSensor");
trillSensor.setMode(Trill::DIFF);
// We recommend a prescaler value of 4
trillSensor.setPrescaler(4); //<<<<<<<<<<<<<<<<<<<<<<<<<<< ALMOST ALWAYS NOT WORKING
// Experiment with this value to avoid corss talk between sliders if they are position close together
trillSensor.setNoiseThreshold(200);
}
This way is always working on all samples:
bool setprescaler = true;
void setup() {
///// as above
}
void loop() {
// Read 20 times per second
delay(50);
// Do it once
if(setprescaler){
setprescaler = false;
trillSensor.setPrescaler(4);
}
...
}
The important thing is that now is OK. Thanks!