Code error and I don't know what to do.

I am trying to make a code where I have 3 LEDs and they blink at different times. I have finished my code but when I press the check mark it keeps saying error with the switchState. I am fairly new to coding and I am not sure what to do. This exactly what it says.

(switchState = digitalRead(2); (That's what I put in the code)

This is what the error says.

Error
'switchState' was not declared in this scope

Hopefully you can help!

Thanks!

Post the code. Post the whole code. Read the how to use this forum-please read sticky to see how to properly post code and some advice on how to ask an effective question. Remove useless white space and format the code with the IDE autoformat tool (crtl-t or Tools, Auto Format) before posting code.

Please include the entire error message. It is easy to do. There is a button (lower right of the IDE window) called "copy error message". Copy the error and paste into a post in code tags. Paraphrasing the error message leaves out important information.

That probably means that the switchState variable was never declared or it was declared in the wrong place. See the reference on variable declaration.

You must declare switchState at the top of the code.
Example-

int switchState = 0;

Or

bool switchState = false;

If you want to use true/false switch state.

..Arnav

switchState = digitalRead(2);

Often (not always), variables with names like "switchState" are used for a single iteration of the loop() function.
As such, it may be unnecessary and inappropriate to give them global scope, as suggested by @ArnavPawarAA (and you shouldn't use 'bool' )

It may simply be the case that int switchState = digitalRead(2); will solve your issue, but while you're fixing that, give pin 2 a meaningful name too :wink:

And, as others have said, post your code.
In code tags.