#include "Adafruit_FreeTouch.h" #define PIN_capacitorPlate_Input 2 // can be digital because it's whether ON/OFF #define PIN_capacitorPlate_ReadOut 4 //must be an analog pin to give a continuous readout Adafruit_FreeTouch qt(PIN_capacitorPlate_ReadOut, OVERSAMPLE_4, RESISTOR_50K, FREQ_MODE_NONE); void setup() { // put your setup code here, to run once: SerialUSB.begin(0); qt.begin(); //pinMode (PIN_capacitorPlate_Input, OUTPUT); //output form the microcontroller //pinMode (PIN_capacitorPlate_ReadOut, INPUT); //input to microcontroller } void loop() { int qt_value = qt.measure(); // read 10-bit value SerialUSB.println(qt_value); delay(200); return; // put your main code here, to run repeatedly: digitalWrite(PIN_capacitorPlate_Input, LOW); //set the value of the pin to low, no charging happening delay (150); //15ms, long discharge digitalWrite(PIN_capacitorPlate_Input, HIGH); //Iput plates should be charging delayMicroseconds (10); //readout V will always be smaller than 3.3V, analogread defaults to comparing values to V= 3.3V int bucket_num = analogRead(PIN_capacitorPlate_ReadOut); Serial.println(bucket_num); delay(150); }