The ECU has the regulator function. I have not seen one (or very very few) fail for that. 99X it is the alternator going bad or a battery with a bad cell.
When are the headlights dimming? Windows going up? Or just random? Everytime at idle? 2Gigawatt Stereo cranked up?
The power system on our cars is 'weak' so any big draw will cause the headlights to dim (themselves a big draw).