I wanted to control the brighhtness of lamp with mega8 by adjusting the pwm. If the measured brightness has a deviation from the desired brightness, then the program will increment or decrement the OCR value, meaning varying 1/255% duty a time (note this change isn't proportional to the error). This will go into a infinite loop until the error drops close to zero. Does anyone know what type of control action this is?
Are you asking for a device that can provide information for the light intensity so that it can be measured from the mcu?
I guess you can use a photoresistor.