LDR issues

hdfbalv:
The problem is when the average is >800

I don't see anything about an average in your code.

What is the promedia variable for?

How long does it take for one iteration of loop() while it works through all those pixel things?

...R