I have connected an FSR (Force Sensitive Resistor) to Arduino Mega 2560 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() {

void loop() {
  int num1 = analogRead(A15);
  • 2
    1. Your code doesn't check the same pin that your schematic shows being connected. 2. That LED with no current limiting resistor can cause bad things to happen to your board. That may have something to do with it. – Delta_G Jun 6 '18 at 2:57
  • image is just for reference. In our scenario we connected to A15 and used Mega. Please ignore the LED part and UNO – Suman Ponmathan Jun 6 '18 at 5:36
  • So basically the picture is just a total lie that has nothing to do with the question? Why post it then? Why not post the actual circuit you used? – Delta_G Jun 6 '18 at 5:51
  • You can't ignore the LED. It may be the thing causing your problem. – Delta_G Jun 6 '18 at 5:52
  • I dont't know how to make the circuit diagram like the above one. – Suman Ponmathan Jun 6 '18 at 6:07

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.


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


It sounds like your Arduino Mega 2560 is broken.

If mega a works and mega b doesn't with the same circuit then mega b must be broken. – Majenko

You can confirm this theory by creating a voltage divider circuit (or use a potentiometer as a voltage divider) and get your Arduino Mega to read that in. It is good practice to measure the voltage using a multi-meter as well. This will help you verify that the voltage read in correspond with the voltage measured and will also help so you do not go over-voltage.

If you are constantly getting 1023 then change it to another analog input. If that still does not work, then try the other Arduino Mega.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.