fade example

why isn't "int ledpin=9" included in void set up. in fact I don't understand why statements are included here at all. they don't seem to be in the program.

in the blink example you don't have anything at the top of the program. the pin assignment is in void set up.

could you put "int ledpin=9" in void set up? is there some reason it would not work there? in the example there is nothing in void set up. couldn't it be left out altogether?

It's because of a neat feature of C called "scope". Basically it just means that variables declared inside a function are only visible there. In your example, the problem is that a variable declared in setup() is not visible in loop(). If not in a function, they are global which means they can be referenced in any function. It's useful indeed for simple programs like you would need on a small processor.

(deleted)