Not declared in scope

Hello.

I am very new to Arduino, so please don't use complicated words or instructions if possible. :slight_smile:
When programming an LED (Trying to replicate the blink example) I get an error saying that the pin name was not declared in the scope. Please help me solve this issue. I have no idea what the problem is.

Capture.PNG

Please post you code within </> code-tags

I found a solution. I needed to put the "int ledpin = 13 into the loop part. :smiley:

You have declared ledpin within the setup() function, hence the variable is only available to be used within that function.

Look at the Blink example and spot the difference.

You should also consider reformatting your code so that lines that require them end in a semicolon. The compiler won't care about the quirky layout in your

int ledpin = 13
;pinMode(ledpin, OUTPUT);

but it looks odd. Putting each statement on its own line also helps to make code more readable for human beings. Consider using the Auto Format command in the IDE. It won't fix syntax and logic errors but it can make code more readable.

I found a solution. I needed to put the "int ledpin = 13 into the loop part.

Do you understand why that fixed the problem ?

Deva_Rishi:
Please post you code within </> code-tags

thanks for telling me!