Servo Library

Hi, I'm a begginer of arduino uno, I've bought it because I want make a small robot. But now I'm here to ask you to help me about Servo Library: in Arduino's software there's some examples, one of this is called Knob, It uses Servo to move a small wheel that I've already make and stuck to the motor.
The problem is that I didn't understand how to use map(). My intent is to control the wheel with a program that performs certain movements that I shall I point in the program.

Thanks for the answers :slight_smile:

The problem is that I didn't understand how to use map().

The map() function maps the input value, such as value returned by analogRead(), from one range, such as the range of values that analogRead() returns, to another range, such as the range of values that a given servo can move to. It seems pretty easy to understand, to me.

I stress I'm a beginner in programmation..
But than can you repeat what you have written before, but in a more concrete with an example?
What happens to the change from the second to the fifth value in map(value,..,..,..,..)?

The first argument is the value to be mapped.

The 2nd and 3rd are the range to map from, for instance 0 to 1023 if the value to be mapped is read from an analog pin.

The 4th and 5th arguments are the range to map to, for instance 0 to 180 if the value is to be mapped to the range of values that a servo can typically move to.

So, if the map() call looks like:

int potVal = analogRead(potPin);
int servoVal = map(potVal, 0, 1023, 0, 180);
Servo.write(servoVal);

and the pot is set about 1/4 of the way from the low end, the value in potVal will be around 250. That value will be mapped to something between 40 and 50, and that value will then be used to position the servo.