function-definition is not allowed here before '{' token ERROR

I don't see a screenshot.

And if it shows code or errors or serial monitor, don't bother. Copy and paste here using code tags (or, in case to big, attach it).