Slowing down as it get closer

Hi,

I wanted to create a code that slows down a motor as the value of the sensor increases to 400 where it comes to a full stop.

Here's what I've done so far:

int m1r=2;
int m1l=3;
int m2f=9;
int m2b=11;
const int sensorMin = 150;
const int threshold = 300;

void setup()  { 
 pinMode(m1r, OUTPUT);
    pinMode(m1l, OUTPUT);
     pinMode(m2f, OUTPUT);
      pinMode(m2b, OUTPUT);
} 

void loop()  { 
  
  
  int sensorReading = analogRead(0);
   int analogValue = analogRead(0);
   
  int range = map(analogValue > threshold, sensorMin<analogValue<threshold,0<analogValue<sensorMin);

  
  switch (range) {
  case 0:   
     for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=5) { 
   
    analogWrite(m2f, fadeValue);         
      
    delay(30);                
    break;
  case 1:    
    
   digitalWrite(m2b,LOW);
   digitalWrite(m2f,LOW);   
   digitalWrite(m1r,HIGH);
   digitalWrite(m1l,HIGH);
    break;
  case 2:   
    digitalWrite(m2f,LOW);
  digitalWrite(m2b,HIGH);
digitalWrite(m1r,HIGH);
   digitalWrite(m1l,HIGH);
    break;
     }

I get an error at this line:
int range = map(analogValue > threshold, sensorMin<analogValue<threshold,0<analogValue<sensorMin);

: error: too few arguments to function 'long int map(long int, long int, long int, long int, long int)'

I guess the problem is that there are not enough conditions?

Thanks

You completely misunderstood the working of map...
http://arduino.cc/en/Reference/Map

You might mean:

map(analogValue,   sensorMin,threshold, 0,sensorMin);

i.e. an anlogValue somewhere between sensorMin and threshold should return a value somewhere between 0 and sensorMin

You also seem to have a "spurious" for() loop in case 0? I don't see an ending brace for it inside the case, or outside of it...?

You really need to learn how to indent properly - you'll find all sorts of issues once you align your code...

:-?