I wrote a vary basic sketch to run some test with this library; this is the code (adapted from a source on WEB):
#include <ADCTouch.h>
ADCTouchClass ADCTouch;
int ref0; //reference values to remove offset
void setup() {
Serial.begin(9600);
delay(1000);
ref0 = ADCTouch.read(A0, 500); //create reference values to
}
void loop() {
int value0 = ADCTouch.read(A0); //no second parameter
value0 -= ref0; //remove offset
Serial.print(value0 > 40); //send (boolean) pressed or not pressed
Serial.print("\t"); //use if(value > threshold) to get the state of a button
Serial.print(value0); //send actual readingc
Serial.print("\t");
delay(100);
}
I included the ADC Touch library 1.0.3 (by Martin 2250) from the Library Manager.
Trying to upload the code I got an error never seen before that I do not understand:
C:\Users\Utente\AppData\Local\Temp\arduino\sketches\D875B039B952878A0C207D7AD80CD4C3\libraries\ADCTouch\ADCTouch.cpp.o (symbol from plugin): In function `ADCTouchClass::read(unsigned char, int)':
(.text+0x0): multiple definition of `ADCTouch'
C:\Users\Utente\AppData\Local\Temp\arduino\sketches\D875B039B952878A0C207D7AD80CD4C3\sketch\TestADCtouch.ino.cpp.o (symbol from plugin):(.text+0x0): first defined here
collect2.exe: error: ld returned 1 exit status
exit status 1
Compilation error: exit status 1
This is unexpected and surprising since the code is minimal and the library, as I see on GitHub, has more then 5 years, so it should have been used a lot.
Thanks