Hello , I'm new to programming with the Arduino. I'm trying to build an interface but I keep getting this error "expected ')' before numeric constant

int switchState=0;

void setup() {
pinMode(2,OUTPUT);
pinMode(3,OUTPUT);
pinMode(4,OUTPUT);
pinMode(5,INPUT);

}

void loop() {
switchState=digitalRead(5);
if (switchState==LOW){
digitalWrite(2,HIGH); //Green LED
digitalWrite(3,LOW); //Red1 LED
digitalWrite(4,LOW); //Red2 LED

}
else {
  digitalWrite(2,LOW);//Green LED
  digitalWrite(3,HIGH); //Red1 LED
  digitalWrite(4,HIGH);//Red2 LED
  
  delay(1000);
  digitalWrite(3 HIGH);
  digitalWrite(4,LOW);
  
  delay(1000);
  
}

}

Near the end of your code you have this:

  digitalWrite(3 HIGH);

There is a comma missing.

Hello, do yourself a favour and please read How to get the best out of this forum and modify your post accordingly (including code tags and necessary documentation for your ask).

Also this post is NOT an introductory tutorial so I moved it to a more suitable place. Please pay attention to the stickies.

Thanks in advance for editing and fixing your post.

C:\stuff\SW\Arduino\_Others\Tst\Tst.ino:21:24: note: in expansion of macro 'HIGH'

i get the above error when i compile your code (i reformatted it, so line #s may be different. the error msg says line 21, column 24

in my listing, line 21 is as follows. that line is missing a comma, "," after the "3".

        digitalWrite(3 HIGH);

that error confuses the compiler which causes it to report additional errors

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.