how create a square signal between 0.2 volt and 0.8 volt
Input: To figure if the input is above or below your reference, you can use a comparator with one input being your signal and the other input being a voltage divider.  This is not shown in my answer.


  I am doing it with an arduino and usign a poteciometer to change the reference between 0.3 volt and 0.7 volt.


Alternatively, one can read the voltage on an Arduino ADC pin and compare to a (flexible!) digital reference.

Output: This circuit should work to create the voltage waveform to be controlled by an Arduino IO pin- you can then buffer the output of the voltage divider with a buffer opamp.

A transistor such as FDN327N will work well with 5V gate voltage.  The resistors might have to be slightly rescaled to give you more precise voltage.  I just did a rough calculation.

\$ V_{outL} = 0.2V = V_{cc} × R_2/(R_2+R_3) \$

\$ V_{outH} = 0.8V = V_{cc} × (R_2+R_1)/(R_1+R_2+R_3) \$

First select \$R_3\$, then calculate \$R_2\$, then \$R_1\$.

Note that the logic is inverted- high IO pin output results in 0.2V and vice-versa.