Hi everyone, I am trying to create a program that reads a POT value into a word variable, then maps it on a scale of 75 to 225 for use with a servo. I found the documentation on the Arduino MAP function which revealed the following:
private long map(long x, long in_min, long in_max, long out_min, long out_max) {
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}
How would I go about writing the equivalent BASIC code. I know that:
-X value would be the word variable value
-"in-min" would be 0
-"out-max" would be 255
-"in-max would be 1023
-"out-min" would be 75
however, when I tried this it did not produce the results I expected.
private long map(long x, long in_min, long in_max, long out_min, long out_max) {
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}
How would I go about writing the equivalent BASIC code. I know that:
-X value would be the word variable value
-"in-min" would be 0
-"out-max" would be 255
-"in-max would be 1023
-"out-min" would be 75
however, when I tried this it did not produce the results I expected.