Alright I have had enough!

I am trying to ceate a code that slows down pin 9 (m2f) gradually has the sensor’s value increases and stops pin 9 at 400.

This is what I got so far:

 int m1r=2;
int m1l=3;
int m2f=9;
int m2b=11;

const int sensorMin = 200;
const int threshold = 400;

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

}

void loop() {
  // read the sensor:
    int analogValue = analogRead(0);


    switch (analogValue) {  
    case 1: 'sensorMin<analogValue<threshold' ;   
    { for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=5) { 
    
    analogWrite(m2f, fadeValue);         
    
    delay(300);  
    }
    }    
      break;
    case 2: 'analogValue > threshold';    
   {  digitalWrite(m2b,LOW);
   digitalWrite(m2f,LOW);  
   digitalWrite(m1r,HIGH);
   digitalWrite(m1l,HIGH);
   }
      break;
    default:
     digitalWrite(m2f,LOW);
  digitalWrite(m2b,HIGH);
digitalWrite(m1r,HIGH);
   digitalWrite(m1l,HIGH);

      }
    }

But IT DOESN"T WORK PROPERLY. Pin 9 remains on LOW(On LOW the motor activates)

Thanks

What is this:
case 1: 'sensorMin<analogValue<threshold' ; ?

The switch statement can only be used when the value or conditional resolves to specific values (the case values).

You want a series of if/else if/else statements, and you want to read up on how to use the if statement.

    int analogValue = analogRead(0);

    switch (analogValue) {  
    case 1:[glow] 'sensorMin<analogValue<threshold' ; [/glow]

What the highlighted text supposed to mean? A new way of entering a comment that I was not aware of? Gives me a compile error.

analogRead returns a value in the range 0 - 1023. It may be hard to hit 1 or 2. Have you tried to print analogValue?

Gives me a compile error.

Really? What version are you running? (there's nothing really wrong with putting in a multi-character constant here, but it won't actually do anything)

What version are you running?

0018 with warnings == errors, as described in this thread: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1278712207/11

Catches plenty of weird mistakes.

I would argue that it isn't an error - not what was wanted or intended, but perfectly allowable by the rules of the language. enabling warnings-as-errors doesn't actually show the error here, which is a lack of understanding of conditionals.

I set warning==errors merely to ensure that the IDE will stop and indicate the suspicious line.