hi there everyone...i need your help with a capacity code.What im trying to do is a toggle switch(when i touch the foil led turn HIGH,when i touch again led turn LOW).the code i have is this one,but i don't know how to add the variable where to store the led status,so it can change every time i touch the foil.
#include <CapSense.h>
CapSense cs_4_2 = CapSense(4,2); // 10 megohm resistor between pins 4 & 2, pin 2 is sensor pin, add Bare Paint
int ledPin1 = 13;
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);
if (total1 > 1100) {
digitalWrite(ledPin1, HIGH); // turn LED ON
} else{
digitalWrite(ledPin1, LOW); // turn LED OFF
}
Serial.println(total1);
delay(100); // arbitrary delay to limit data to serial port
}
thank you so much for help...
