Go Down

Topic: Expected `;' before '{' token (Read 1 time) previous topic - next topic

roberto03

Hi, I'm running the following code
Code: [Select]


#include <CapacitiveSensor.h>
CapacitiveSensor capSensor = CapacitiveSensor(4,2);

int threshold = 1000;
const int ledPin = 12;

void setup() {
  Serial.begin(9600);
  pinMode(ledPin, OUTPUT);
}

void loop() {
  long sensorValue = capSensor.capacitiveSensor(30);
  Serial.println(sensorValue);
 
  if(sensorValue > threshold)
  {
    digitalWrite(ledPin, HIGH);
  }
  else
  {
   digitalWrite{ledPin, LOW};
  }
 
  delay(10);
}



And I don't understand why they tell me this error

Code: [Select]

p13_lamp_ino.ino: In function 'void loop()':
p13_lamp_ino:23: error: expected `;' before '{' token

CrossRoads

I'm guessing you don't have this library located in the correct place:
CapacitiveSensor.h

Scroll up in the bottom part of the IDE window, or drag the bottom up to make the viewing are bigger, and see if that is noted.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

roberto03

I'm sorry, but there is no signaled problem with the
"CapacitiveSensor.h"

The only error is:
p13_lamp_ino.ino: In function 'void loop()':
p13_lamp_ino:23: error: expected `;' before '{' token

oqibidipo

Look very closely at the first digitalWrite(...) and you will see what is wrong with the second digitalWrite{...}.

roberto03

It works now, almost impossible to spot.
A big thank you then...

Go Up