I keep getting errors while compiling my chicken door sketc, need help debugging

redneck:
I am trying to write a function where the light level read on A0 is taken 10 times with a delay of (1000) between each reading. These 10 readings will then be averaged and the result given to the if statements to determine if the door should open or close. This at least in my thinking would keep the door closed should the neighbors headlights shine on the sensor or lightning strikes occur.

In that case, you need to declare and implement the function outside of all other functions (like how you did with closeDoor and openDoor) and call it from within the loop.