This will be my first attempt at anything with an Arduino, infact with coding at all. I've read a few forum posts and watched some youtube videos about stepper motor control but want to ensure I get the approach to the project right before getting into the details of the code. My car has an old capillary driven temperature gauge. These things are easily broken and its a common complaint among the owners due to repair costs and turn-round time.
To avoid this problem whilst retaining the original look of the dashboard I'd like to replace the mechanical workings of the gauge with a stepper motor controlled by an Arduino Nano. I've ordered a bipolar stepper, L298 driver, a Bosch NTC Temp sensor and a Nano. I understand that the Arduino can't read resistance directly, therefore a fixed value resistor is required to set up a potential divider circuit from which coolant temperature can be calculated.
The issue I have is with the stepper control strategy and converting voltage/temperature into the number of steps the motor is required to move. The gauge has a stop positioned at the bottom end of the scale (40 Deg C) but no stop at the upper end of the scale (120 Deg C).
I think I should run some setup code to drive the stepper against the stop, with the number of steps/run time calculated by the number of steps/time it takes to wind back from the max temp position, to ensure the needle starts from the fully cold position every time as a reference point. For continued temperature monitoring I suspect I require a lookup table which converts voltage received on the input pin to a number of steps up from the cold stop that the motor is required to turn.
Finally as the code will continually loop I expect I should set a variable which record the number of steps from cold the motor is currently on loop 'n', and then on loop n+1 the new step position can be calculated, the difference between 'n' and 'n+1' positions found and the motor moved the required number of steps forward/back.
Overall is this a sound approach to the project. If not please can you advise a suitable method?
Secondly, assuming a lookup table is the correct approach, how do I interpolate between values in the table?