I have noticed that in the demo script of Grove - Capacitive Touch Slide Sensor (CY8C4014LQI) I always get different values for the 5 slider bars (in the serial monitor) when I repeat touching them. Why?
How can I program an output to the serial monitor of “slider 1” if the first bar of the slider is pressed, “slider 1+2” output when pressing the first two slideer bars, etc. Furthermore, how can I keep the led above the slider on in correspondence to the touched bar?
Demo script:
[code]#include “Seeed_CY8C401XX.h”
#ifdef ARDUINO_SAMD_VARIANT_COMPLIANCE
#define SERIAL SerialUSB
#else
#define SERIAL Serial
#endif
CY8C sensor;
void setup()
{
SERIAL.begin(115200);
sensor.init();
}
void loop()
{
u8 value=0;
sensor.get_touch_button_value(&value);
SERIAL.print(“button value is”);
SERIAL.println(value,HEX);
if(value&0x01)
SERIAL.println(“button 1 is pressed”);
if(value&0x2)
SERIAL.println(“button 2 is pressed”);
sensor.get_touch_slider_value(&value);
SERIAL.print("slider value is");
SERIAL.println(value,HEX);
SERIAL.println(" ");
delay(1000);
}[/code]