user42383: I have connected an FSR (Force Sensitive Resistor) to  as per image(edited name for avoiding mismatch). When I measure the voltage b/w two pins of fsr, voltage changing as per pressure applied. But analogRead always returns 1023. But my another Mega works good with same code and configurations. Can someone guide me to correct it. Thanks in advance.

void setup() {
  Serial.begin(19200);
}

void loop() {
  int num1 = analogRead(A15);
  Serial.println(num1);
  delay(1500);
}


user79717: I had the same problem when simulating a similar circuit in proteus software. I was able to solve it by supplying power with an external dc input terminal to the arduino board 5v pin.

user58541: I had a similar problem when I ported my code from an Arduino Due to an Arduino Mega. I was able to solve this problem by adding the following call in the setup function.
analogReference(DEFAULT);

It seems that in some other Arduinos, the analog reference will be selected automatically, but at least the Arduino Mega needs it.

42383: <p>I have connected an FSR (Force Sensitive Resistor) to <strong><a href="https://i.stack.imgur.com/Wr01A.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Wr01A.jpg" alt="Arduino Mega 2560"></a></strong> as per image(edited name for avoiding mismatch). When I measure the voltage b/w two pins of fsr, voltage changing as per pressure applied. But analogRead always returns <strong>1023</strong>. But my another Mega works good with same code and configurations. Can someone guide me to correct it. Thanks in advance.
</p>

<pre class="lang-cpp prettyprint-override"><code>void setup() {
  Serial.begin(19200);
}

void loop() {
  int num1 = analogRead(A15);
  Serial.println(num1);
  delay(1500);
}
</code></pre>
 79717: <p>I had the same problem when simulating a similar circuit in proteus software. I was able to solve it by supplying power with an external dc input terminal to the arduino board 5v pin.</p>
 58541: <p>I had a similar problem when I ported my code from an Arduino Due to an Arduino Mega. I was able to solve this problem by adding the following call in the setup function.</p>

<pre><code>analogReference(DEFAULT);
</code></pre>

<p>It seems that in some other Arduinos, the analog reference will be selected automatically, but at least the Arduino Mega needs it.</p>
