Arrch:
void loop(){
averagelightLevel(){
...
}
...
}
What exactly are you trying to do here? You've defined averagelightLevel as a variable, and now you are trying to define it as a function. On top of that, you are trying to define it within another function, which doesn't work. 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.