- first off, I would make the debug printouts a little more descriptive,
I second this.
- also, your case statements look a little weird to me, they probably work
ok, but are usually written "without" the braces. ???
The braces are fine. They are not required, but adding them doesn't hurt.
- one usually adds a default: line at the end of the switch to handle nonmatches.
The default case is optional, and can be left out if it would be empty anyway.
float volts4 = analogRead(IRpin4)*0.0048828125; // value from sensor * (5/1024) - if running 3.3.volts then change 5 to 3.3
float LeftSide = 65*pow(volts3, -1.10); // worked out from graph 65 = theretical distance / (1/Volts1)S - luckylarry.co.uk
Does the actual distance matter? There is a value read from the pin that the sensor is attached to. It might be simpler to just use that value, instead of all this mucking around.
In any case, why is LeftSide based on volts3? Should it be a function of volts4?