How to make software voltage divider?

You can use some fixed resistors in the divider which are shorted out with an opto fet.