I'm implementing a PID-control algorithm to a robot I'm currently building using Arduino.
My question is more related to the logics of programming.
I have to calculate a variable, an error, int eps. This eps will be between -7 and +7.
From the robot I acquire an input in the form of a double with values between 0 and 7000.
My algorithm has to work something like this:
if(input >= 500){
if(input >= 1000){
if(input >= 1500){
..........
}
}else{
eps = 6;
}
}else{
eps = 7;
}
And so on...
In other words I have to assign a value to eps that will be determined by which interval the input is included in.
My question is what would be the most efficient, time and resource-saving way of doing this?
I'm using Arduino and their own IDE, not Eclipse.