Capsense

Hello, I'm new to Arduino. Can somebody please explain line by line what exactly is happening in this code?

Demo Sketch
#include <CapSense.h>

/*

  • CapitiveSense Library Demo Sketch
  • Paul Badger 2008
  • Uses a high value resistor e.g. 10 megohm between send pin and receive pin
  • Resistor effects sensitivity, experiment with values, 50 kilohm - 50 megohm. Larger resistor values yield larger sensor values.
  • Receive pin is the sensor pin - try different amounts of foil/metal on this pin
  • Best results are obtained if sensor foil and wire is covered with an insulator such as paper or plastic sheet
    */

CapSense cs_4_2 = CapSense(4,2); // 10 megohm resistor between pins 4 & 2, pin 2 is sensor pin, add wire, foil
CapSense cs_4_5 = CapSense(4,5); // 10 megohm resistor between pins 4 & 6, pin 6 is sensor pin, add wire, foil
CapSense cs_4_8 = CapSense(4,8); // 10 megohm resistor between pins 4 & 8, pin 8 is sensor pin, add wire, foil

void setup()
{

cs_4_2.set_CS_AutocaL_Millis(0xFFFFFFFF); // turn off autocalibrate on channel 1 - just as an example
Serial.begin(9600);

}

void loop()
{
long start = millis();
long total1 = cs_4_2.capSense(30);
long total2 = cs_4_5.capSense(30);
long total3 = cs_4_8.capSense(30);

Serial.print(millis() - start); // check on performance in milliseconds
Serial.print("\t"); // tab character for debug windown spacing

Serial.print(total1); // print sensor output 1
Serial.print("\t");
Serial.print(total2); // print sensor output 2
Serial.print("\t");
Serial.println(total3); // print sensor output 3

delay(10); // arbitrary delay to limit data to serial port
}

This is a sample that comes with the Capsense library. Thanks.

Hello, I'm new to Arduino. Can somebody please explain line by line what exactly is happening in this code?

That code looks pretty straightforward to me. There are even good comments.

Why don't you explain what you don't understand, so we can focus on that.