Just as a preface I'm new to C++, I'm trying to get capacitive touch working on my arduino. The code however, is not working properly. I get an error on line 10 about the '{' I tried to remove the ';' on line 9 but it still gave me an error. Any help would be appreciated, thanks!
int led = 10;
int state = HIGH;
boolean yes;
boolean previous = false;
int debounce = 200;
CapacitiveSensor cs_4_2 = CapacitiveSensor(4,2);
{
cs_4_2.set_CS_AutocaL_Millis(0xFFFFFFFF); //Calibrate the sensor...
pinMode(led, OUTPUT);
}
voidloop()
{
long total1 = cs_4_2.capacitiveSensor(30);
if (total1 > 60){yes = true;}
else {yes = false;}
// to toggle the state of state
if(yes == true && previous == false && millis() - time>debounce){
if(state == LOW){
state = HIGH;
}
else
state = LOW;
time = millis();
}
digitalWrite(led, state);
previous = yes;
Serial.println(millis()-time);
delay(10);
int x = map(total1, 100, 800, 0, 255);
analogWrite(13, x);
`
Aucun commentaire:
Enregistrer un commentaire