Loop not naming type in project 02

This is my code but for some reason the LEDs don't light up at all and the loop at the very end does 'not name a type'

'''''''''''''''''''''''''''''''''''''''''''''''
int switchState = 0;
void setup() {
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(2, INPUT);
}
void loop() {
switchState = digitalRead(2);
// this is a comment
if (switchState== LOW) {
// button pressed
digitalWrite(3, HIGH);
digitalWrite(4, LOW);
digitalWrite(5, LOW);
}
else { // button pressed
digitalWrite(3, LOW);
digitalWrite(4, LOW);
digitalWrite(5, HIGH);
delay(250); //this will slow down the leds
digitalWrite(4, HIGH);
digitalWrite(5, LOW);
}
} loop

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Welcome to the forum

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use code tags (the </> icon above the compose window) to make it easier to read and copy for examination

Did you mean that to be a comment indicating the end of the loop() function? that would be:
} // loop

I'm pretty sure it just means to loop all the code from void loop code but idk
ps i tried

 else { // button pressed
  digitalWrite(3, LOW); 
  digitalWrite(4, LOW); 
  digitalWrite(5, HIGH);
  delay(250); //this will slow down the leds
  digitalWrite(4, HIGH);
  digitalWrite(5, LOW);
 }
} // loop
 

@johnwasser

the LEDs don't even light up...

It doesn't. It's not valid C and that's why you got the error message.

And what happened then?

The LEDs will not light until your code has been compiled and uploaded to the Arduino.

@PaulRB
The LEDs don't light up

actually I think I've got it. i frogot to write in the second delay
I'm in a brightly lit room so maybe they're just dim?

So your sketch is now compiling without error and uploaded to the Arduino? Post the updated code please. If you still need help, be sure to use code tags as you were asked to do. You have still not corrected your original post by adding the code tags there.

@PaulRB
the LEDs still don't turn on...

int switchState = 0;
void setup() {
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(2, INPUT);
}
void loop() {
  switchState = digitalRead(2);
  // this is a comment
 if (switchState== LOW)  {
  // button pressed
  digitalWrite(3, HIGH); 
  digitalWrite(4, LOW); 
  digitalWrite(5, LOW);
 }
 else { // button pressed
  digitalWrite(3, LOW); 
  digitalWrite(4, LOW); 
  digitalWrite(5, HIGH);
  delay(250); //this will slow down the leds
  digitalWrite(4, HIGH);
  digitalWrite(5, LOW);
  delay(250); //slow it down again
 }
} // loop
 

Thanks for using code tags.

I would expect at least one led to light. Please post a schematic.

sorry, accidentally deleted this comment.
do you mean a photo of the setup?

No

a diagram, plan, or drawing:

the tutorial?

It might help, but a schematic drawing would be much clearer. Hand drawn will be ok.

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