Thank you for answering, ardshark.
ardshark:
If I had to guess Id say that rollingAverage is a variable added by the user and is just not declared properly. I don’t see it defined in the library.
Thought so too, but I’m not proficient with textual programming (I’m from the visual programming domain) so proper structures and definitions are just vague assumptions from my side …
Here’s the code:
/*
Through-Glass Doorbell
Reads the difference in capacitance from a piece of aluminium foil, or foil tape, applied
to one side of a glass pane, when touching the glass on the other side. The Arduino sketch
then triggers a solenoid which rings a bell.
The sketch relies on two libraries to work properly, first the Capacitive Sensing Library
( http://playground.arduino.cc/Main/CapacitiveSensor ) to read and interpret change in
capacitance on the aluminium foil, and second the Average Library to perform a bit of
data filtering, and smooth out values ( http://playground.arduino.cc/main/average ).
The circuit:
A piece of conductive material (aluminium foil) connected between two digital pins on
the Arduino board, with a high value resistor connected in between. Power is provided
externally from a 6-12V power supply and is connected to the Vin pin on the Arduino.
Power is also connected to a solenoid which is controlled with a TIP120 transistor
conected to an Arduino digital pin with a 2.2kOhm resistor inbetween the digital pin
and the base on the transistor. A 1N4001 rectifier is added between the leads of the
solenoid.
Refer to http://www.instructables.com/id/Through-Glass-Doorbell/ for full schematic.
created 15 Apr. 2015
by Daniel Jansson
http://www.switchandlever.com
This code is in the public domain.
*/
#include <Average.h> // Averaging library:
#include <CapacitiveSensor.h> // Capacitive sensing library:
#define AvgCnt1 50 // set up a large sample to average
#define AvgCnt2 10 // set up a smaller sample to average
int d[AvgCnt1]; // create array to hold the large sample of data to average
int e[AvgCnt2]; // create array to hold the smaller sample of data to average
CapacitiveSensor cs_4_2 = CapacitiveSensor(4,2); // 10M resistor between pins 4 & 2, pin 2 is sensor pin, add a wire and or foil if desired
int solenoid = 12; // attach the solenoid to digital pin 12
int multiplier = 1.8; // the change in capacitive value which will trigger the solenoid, will need to be fine tuned
int dingPoke = 5; // for how many milliseconds to engage the solenoid, will need to be adjusted depending on your solenoid and bell
int dingPause = 500; // how long to pause (disengage solenoid) between dings
unsigned long timer = 0; // stores the time used to make sure it doesn't trigger too often
void setup()
{
cs_4_2.set_CS_AutocaL_Millis(0xFFFFFFFF); // turn off autocalibrate on channel 1 - just as an example
Serial.begin(9600); // start serial communication for debug purposes
pinMode(solenoid, OUTPUT); // set the solenoid pin to output
}
void loop()
{
unsigned long start = millis(); // stores the start time of every loop
unsigned long total = cs_4_2.capacitiveSensor(30); // read capacitive data
unsigned int capAvg = rollingAverage(d,AvgCnt1,total); // take, and average, a large sample of readings
unsigned int capAvgShrt = rollingAverage(e,AvgCnt2,total); // take, and average, a small sample of readings
Serial.print("Mean: "); // printing out data to serial monitor for debugging purposes
Serial.print(capAvg);
Serial.print("\t");
Serial.print(capAvgShrt);
Serial.print("\t");
Serial.println(total);
if (capAvgShrt > (capAvg*multiplier)){ // trigger if the small sample of readings is bigger than the large sample, times multiplier
if(timer < millis()){ // trigger only if at least five seconds has passed since the last time being triggered
Serial.println("Success!");
timer = millis()+5000; // reset timer to be current time, plus five seconds
ding(); // trigger 'ding' function
}
else { // otherwise, do nothing
}
}
delay(5); // short delay for stability
}
void ding(){
digitalWrite(solenoid, HIGH); // activate solenoid
delay(dingPoke); // keep engaged for 'dingPoke' milliseconds
digitalWrite(solenoid, LOW); // deactivate solenoid
delay(dingPause); // keep off for 'dingPause' milliseconds
digitalWrite(solenoid, HIGH);
delay(dingPoke);
digitalWrite(solenoid, LOW);
delay(dingPause*2);
}
The part in question (so far) is
unsigned int capAvg = rollingAverage(d,AvgCnt1,total); // take, and average, a large sample of readings
unsigned int capAvgShrt = rollingAverage(e,AvgCnt2,total); // take, and average, a small sample of readings
ardshark:
Keep in mind too that you can always write around a lacking in a library.
Sounds good, but please I’d need help to get this done properly … 
FYI, using Arduino 1.6.8 here. Thanks for the code tags 
Moderator edit: CODE TAGS