Help with software to control some solenoids....

Let's get the warning out of the way. The Atmel data sheet on this processor says it should not be used for any automotive application.

Cases 1 and 2 are just special cases of 3.
Case 4 has been done to death on this forum and requires that you use a potential divider.

Now case 3 is where it can be complected. What you have in effect is a closed loop feedback system and this can be implemented in a number of ways. The classic servo control has integrators and step response to consider and involves a whole bunch of math to achieve either an over damped, under damped or critically damped system.

Also do a google on damping and look at the images.

The other alternative is the sort of on / off control used in things like electric cookers and fridges. Go full belt until it gets to where it is going and then shut it off until it drifts away. This is much easier to implement but the result is rougher.