Mapping the sensor output to another set of values through Arduino Programming-map() function

Directly jumping on the piece of code/sketch:

// set the mappedSensorValue to the value of the map() function
int mappedvalue = map(sensoroutputvalue, 0, 1023, 0, 9);

Here the variable "mappedvalue" will store the mapped value or range conserved value which is a modified form of the sensor value that is got feeded in the Arduino.

When ever a sensor return a particular reading, which is actually in the form of voltage, the ADC of Arduino converts or dissects the value in 1024 values, i.e., the lowest value is being assigned to 0 & the highest[particularly +5 volts or the voltage value at ARef pin] be 1023.

But why are we gonna need that much of value variations. Some time even scale of 1 to 10 is enough.[actully more than enough in case of just a estimated result]. So by map() function of Arduino Programming Language.

The map [map()] function as you are able to see in the above example, has actually 5 arguments!
1st, is the "sensoroutputvalue", as the name is suggesting, it the value that sensor gives to the Arduino.
2nd is the "0", which is actually the lowest value that Arduino ADC can give.
3rd is the "1023", which is actually the highest value that Arduino ADC can give.
4th is again a "0", well that actually depends on the user choice/need. If we want a range of 6 to 9 we will set this arguement as just "6".
5th is "9", which is actually the highest value of the user defined range of mapping.

So after executing this function the mapped value will be stored in the variable named "mappedvalue".

the ranges 0 through 9 based upon the pattern we’ve just described will be like

0 To 102 -->0
103 To 205 -->1
206 To 308 -->2
309 To 411 -->3
412 To 514 -->4
515 To 617 -->5
618 To 720 -->6
721 To 823 -->7
824 To 926 -->8
927 To 1023 -->9

here "-->" denotes the mapping, & the range of values to the left is the range of sensor output, as interpretted by ADC & the right value will be the mapped value of that range.

Map function [map()] is just doing a simple arithmetic calculation, for mapping out the values.

It is like:-
[sensoroutputvalue/1024]*9, here 9 is the max limit of the required mapped value.