user45615: Arduino Uno with ATMega328P Processor.analogWrite is not working properly in if statement. It changes the brightness of the LED as if there wasn't any if statement at all.
There are 2 potentiometers to create an intervall in which to program increases of the LED brightness, starting at 40% of the maximum. When it's lower than the minimum value, the LED is turned off.
int ledPin = 6;
int sensorPot = 1; // it's a potentiometer for now
int maxPot = 7; // potentiometer 
int minPot = 3; // potentiometer
int fortypercent = 255*0.4;
int brightness = 0;

void setup() {
  pinMode(ledPin, OUTPUT);
  pinMode(sensorPot, INPUT);
  pinMode(maxPot, INPUT);
  pinMode(minPot, INPUT);
  Serial.begin(9600);
}

void loop() {
  int start = analogRead(minPot);
  int maxVal = analogRead(maxPot);
  int sensor = analogRead(sensorPot);
  Serial.println(sensor/4);
  Serial.println(start/4);
  Serial.println(maxVal);
  if(sensor/4 > start/4) {
    analogWrite(ledPin,sensor/4);
  } else if(sensor = baslangic) {
    analogWrite(ledPin,LOW);
  } else if ((start < sensor < maxVal)) {
    brightness = sensor/4 - fortypercent;
    analogWrite(ledPin,brightness); 
  } else if (sensor = maxVal) {
    analogWrite(ledPin , 255);
  }
}


user27653: ORIGINAL RESPONSE, BASED ON DIFFERENT CODE
You are comparing sensorValue to see if it's ever less than minValue.
However, you have mapped sensorValue to range from 0 to 255, and minValue is set at 0. How can anything from 0-255 be less than zero?
NEW RESPONSE, BASED ON UPDATED CODE
One of your if statements: else if(sensor = baslangic) is not comparing, but assigning baslangic to sensor. To compare, use ==.
Your other if statement: else if ((start < sensor < maxval)) is wrong. C++ doesn't work this way. Maybe you want: if ((start<sensor) && (sensor<maxval))? 
Instead, your statement evaluates like if ( (start<sensor) < (maxval) ), which means you are comparing the TRUE or FALSE of (start<sensor) to the int that is maxval.

45615: <p>Arduino Uno with ATMega328P <code>Processor.analogWrite</code> is not working properly in if statement. It changes the brightness of the LED as if there wasn't any if statement at all.</p>

<p>There are 2 potentiometers to create an intervall in which to program increases of the LED brightness, starting at 40% of the maximum. When it's lower than the minimum value, the LED is turned off.</p>

<pre><code>int ledPin = 6;
int sensorPot = 1; // it's a potentiometer for now
int maxPot = 7; // potentiometer 
int minPot = 3; // potentiometer
int fortypercent = 255*0.4;
int brightness = 0;

void setup() {
  pinMode(ledPin, OUTPUT);
  pinMode(sensorPot, INPUT);
  pinMode(maxPot, INPUT);
  pinMode(minPot, INPUT);
  Serial.begin(9600);
}

void loop() {
  int start = analogRead(minPot);
  int maxVal = analogRead(maxPot);
  int sensor = analogRead(sensorPot);
  Serial.println(sensor/4);
  Serial.println(start/4);
  Serial.println(maxVal);
  if(sensor/4 &gt; start/4) {
    analogWrite(ledPin,sensor/4);
  } else if(sensor = baslangic) {
    analogWrite(ledPin,LOW);
  } else if ((start &lt; sensor &lt; maxVal)) {
    brightness = sensor/4 - fortypercent;
    analogWrite(ledPin,brightness); 
  } else if (sensor = maxVal) {
    analogWrite(ledPin , 255);
  }
}
</code></pre>
 27653: <p><strong>ORIGINAL RESPONSE, BASED ON DIFFERENT CODE</strong></p>

<p>You are comparing <code>sensorValue</code> to see if it's ever less than <code>minValue</code>.</p>

<p>However, you have mapped <code>sensorValue</code> to range from <code>0</code> to <code>255</code>, and <code>minValue</code> is set at <code>0</code>. How can anything from 0-255 be less than zero?</p>

<p><strong>NEW RESPONSE, BASED ON UPDATED CODE</strong></p>

<p>One of your <code>if</code> statements: <code>else if(sensor = baslangic)</code> is not comparing, but assigning <code>baslangic</code> to <code>sensor</code>. To compare, use <code>==</code>.</p>

<p>Your other <code>if</code> statement: <code>else if ((start &lt; sensor &lt; maxval))</code> is wrong. C++ doesn't work this way. Maybe you want: <code>if ((start&lt;sensor) &amp;&amp; (sensor&lt;maxval))</code>? </p>

<p>Instead, your statement evaluates like <code>if ( (start&lt;sensor) &lt; (maxval) )</code>, which means you are comparing the <code>TRUE</code> or <code>FALSE</code> of <code>(start&lt;sensor)</code> to the <code>int</code> that is <code>maxval</code>.</p>
