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 
}
示例#3
0
//*********************************************************************************************************
void checkButtons()
{
	// last time the respective button was pressed; used for debouncing;
static unsigned long timeBtnMenu;
static unsigned long timeBtnSet;
static unsigned long timeBtnPlus;

  if (but_1.capSense(30)  > CapThreshold) 
  {
    if (abs(millis() - timeBtnMenu) < BOUNCE_TIME_BUTTON)  return;

    if(buttonCallback != NULL)
      buttonCallback(BUTTON_MENU);

    timeBtnMenu	=	millis();
  }	

  if (but_2.capSense(30) > CapThreshold) 
  {
    // debouncing;
    if (abs(millis() - timeBtnSet) < BOUNCE_TIME_BUTTON)  return;

    if(buttonCallback != NULL)
      buttonCallback(BUTTON_SET);

    timeBtnSet	=	millis();
  }

  if (but_3.capSense(30) > CapThreshold) 
  {

    // debouncing;
    if (abs(millis() - timeBtnPlus) < BOUNCE_TIME_BUTTON)  return;
    if(buttonCallback != NULL)
      buttonCallback(BUTTON_PLUS);
    timeBtnPlus	=	millis();
  }

}