I am trying to implement the CapacitiveSensor 4.0 library on my project but I face some trouble.
The problem is that I don't want the number of capacitive sensors and their pin numbers to be predefined at the program (like they are in the example sketch of the lib). I want to save the configuration (number of sensors and their pin numbers) to EEPROM, retrieve it on each start up and define the capacitive sensors accordingly. The only thing that is known is the 'send pin' that is always the same and that the number of sensors is 0-4.
Here is a minimal sketch that shows what I'm trying to do:
#include <CapacitiveSensor.h>
int sensor_count;
int sensor_pin[3];
int send_pin = 4;
CapacitiveSensor cs[3];
void setup() {
/* here goes a procedure to access the EEPROM,
get the number of sensors and their pin numbers,
and put them in an array. The number of sensors
will always be 0-4. */
if (sensor_count >= 1) cs[0] = CapacitiveSensor(send_pin,sensor_pin[0]);
if (sensor_count >= 2) cs[1] = CapacitiveSensor(send_pin,sensor_pin[1]);
if (sensor_count >= 3) cs[2] = CapacitiveSensor(send_pin,sensor_pin[2]);
if (sensor_count == 4) cs[3] = CapacitiveSensor(send_pin,sensor_pin[3]);
}
void loop() {
// poll the sensors once in a while and do other stuff
}
Unfortunately I am getting this error when trying to compile:
capacitive_sensor:10: error: no matching function for call to 'CapacitiveSensor::CapacitiveSensor()'
Z:\Documents\Arduino\libraries\CapacitiveSensor/CapacitiveSensor.h:24: note: candidates are: CapacitiveSensor::CapacitiveSensor(uint8_t, uint8_t)
Z:\Documents\Arduino\libraries\CapacitiveSensor/CapacitiveSensor.h:20: note: CapacitiveSensor::CapacitiveSensor(const CapacitiveSensor&)
I hope someone here can help me. Thanks in advance!