title: Value of variable doesn't change
body: <p>I am writing this code for a photoresistor on the arduino. I am supposed to attach servos to the photoresistor so that it will work as a moving solar panel. However, upon running the code I note that the value of variable pos (which is supposed to store the angle having max amount of light) does not change. What can I do about it?  </p>
  
  <pre><code>int val1, val2, temp = 1000;  
  int pos = 0;  
  
  void setup() {   
    Serial.begin(9600);  
  }
  
  void loop() {  
    int sensorValue = analogRead(A0);    
    int val = map(sensorValue, 0, 1023, 0, 100);  
    Serial.println(val);  
    for(int i=0; i&lt;180; i++){  
      val1 = map(sensorValue, 0, 1023, 0, 100);  
      if(val1 &lt;= temp){  
        temp = val1;  
        pos = i;  
      }  
      delay(15);  
    }  
    Serial.println(pos);   
    delay(1000);  
  }
  </code></pre>