Reference voltage for a voltage comparater in a Solar Electric system?

so i made a solar charger ,which charges a 6v battery with a 12v panel...my question is that i would like to have some kind of indication,which could tell me when the battery's full / empty...but how can i feed a reference voltage to the comparator because the voltage from the panel will vary upon light,and so that would change the reference voltage...similarly when the battery's low(ill use a voltage divider from the battery to the comparator), the reference voltage again would vary...

how can i have a constant reference voltage,when the voltage of the panel varys upon light?

You can use a voltage regulator to get a reference voltage (such as the 3.3v regulator already on most Arduino boards), or use the internal 1.1v (approx) reference in the mcu itself.

There are also "voltage reference" chips that work like a voltage regulator but only handle a tiny amount of power, their purpose is to generate a stable accurate voltage precisely for this sort of purpose. A standard voltage regulator may take a lot more idle current, or actually require there be a load current in order to be stable.

I would recommend the MAX6029 as a voltage reference chip. Very low voltage, and pretty accurate