From: skini on
I need to use the Matlab for controling water pump speed which will control water level in a small tank. Water pump (windshield-water pump, 12v) is connected to DC-DC converter controller which is control by Matlab (0-5V).
Water level is messured by pressure sensor and this is INPUT.
So this is what i need from Matlab:

When input in Matlab is 0-0.5V, OUT must be 5V.
When IN is 2.5V, OUT must be 3V. If Input then raises, OUT must decrease for 0.5V. If it raises again, then OUT must again decrease by 0.5V. And so on.
If Input lowers then OUT must raise for 0.5V. And if it sill raises, again 0.5V increase in OUT and so on...
When IN is 4V, OUT must be 0V.

So if someone can help me to write code in Matlab that will do that.
Thank You.