void loop() { long start = millis(); long total1 = cs_4_2.capacitiveSensor(30); long total2 = cs_4_6.capacitiveSensor(30); long total3 = cs_4_8.capacitiveSensor(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 }
void capsense() { long total = cs_0_2.capacitiveSensor(30); //Read sensor with 30 samples Serial.print("Sense Value: "); Serial.println(total); // print sensor output }
void CapSenseMonitor::connect_sensor(UART_Ptr the_uart) { CapacitiveSensor cs; auto sensor_index = m_sensors.size(); cs.set_thresholds(*m_cap_sense_thresh_touch, *m_cap_sense_thresh_release); cs.set_charge_current(*m_cap_sense_charge_current); cs.set_touch_callback(std::bind(&CapSenseMonitor::sensor_touch, this, sensor_index, std::placeholders::_1)); cs.set_release_callback(std::bind(&CapSenseMonitor::sensor_release, this, sensor_index, std::placeholders::_1)); cs.set_timeout_reconnect(5.f); if(cs.connect(the_uart)){ m_sensors.push_back(cs); } }
void setup() { cs_4_2.set_CS_AutocaL_Millis(0xFFFFFFFF); // turn off autocalibrate on channel 1 - just as an example Serial.begin(9600); }