Code problem with LED

You have miss matched { }.
I suspect you are one } short at the end of your loop()

To check, move the pointer to just after the brace and click, you will see the matching brace in a box.
When you do you will find the last brace in the loop() function matches the last else. Therefore the compiler thinks you are trying to define a function inside the loop() function, that is what it is telling you.