This library for Arduino enable you to use capacitive sensors. This library is faster than any other libraries before.
This library uses math.h.
The resistor decide the time of charging. receivePin must be analog input pin.
Capacitive sensors are pseudo capacitors. Your Arduino will measure the time of charging them, and if the time is long, it decides that a conductor touching on the sensor.
The equation of the sensed voltage will be:
$$
V = V_0(1-e^{-\frac{1}{RC}t})
$$
In this library, the time when
Actually, we do not have to measure the time until
The expected returning time
See also example program.
#include <FastCapacitiveSensor.h>
FastCapacitiveSensor sensor1;
sensor1.begin(A0, A1, 5.0, 10, 10, 0.2);
arguments:
void begin(sendPin, receivePin, maxVoltage, frequency, breakThreshold, excludeRatio);
sendPin is a pin that you can use the function digitalWrite on.
receivePin is read out with analogRead, so it should be an analog pin.
maxVoltage is the voltage of the sendPin. It is
frequency is how many times the touch function tries sensing.
breakThreshold is the threshold of breaking sensing. The unit is micro seconds. the touch function finish sensing on the breakThreshold time, and after that, calculate the expected time of sensing. It is
excludeRatio is the ratio of exclusion of sensed values. Must be larger than or the same as 0 and smaller than 0.5.
sensor1.touch()
The return value is the sensed (or calculated) time in units of micro seconds. The type is double.