Analog inputs are not working I have an Arduino ATmega8A. I tried to use its analog inputs. Initially I used a normal program without using aref and connected potentiometer at A0 and I got expected values.

After that for accuracy I used a LM431 circuit for 2.5V reference. Programmed the Arduino and I again got expected values. It was working properly until this stage.

For more accuracy I tried using LM317 1.25 reference as voltage reference for aref pin. The problem comes here. When I run the program initially the values were changing from maximum value. Like it was showing 1.25, when I changed the resistance on the potentiometer it was changing its value for a sec. and again showing maximum value 1.25. I off the circuit and tried it once again. At that time there were no changes and it was giving me maximum value.

I thought there is a problem in my LM317 circuit or my LM317.

I connected the LM431 circuit again and changed the program and run it once again, the outputs were giving me maximum value i.e. 2.5 ,outputs values  were not changing as I change resistance on potentiometer. So I tried with normal program without using aref pin, the same thing happened there.

This is program without using potentiometer

int r;
float v;

void setup()
{ 
  analogReference(EXTERNAL);
  pinMode(A0, INPUT);
  Serial.begin(9600);
}

void loop()
{    
  r = analogRead(A0);
  v = (5.0 / 1023.) * r;
  Serial.println(v);
  delay(250);
}


The potentiometer is connected at A0 and the other 2 pins are connected to + 5v and gnd. Initially it was working properly

The program using vref

#include &lt;LiquidCrystal.h&gt;
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
float exRef = 2.52;

int r;
float v;

void setup()
{
  analogReference(EXTERNAL);
  analogWrite(6, 20);
  lcd.begin(16, 2);
  pinMode(A0, INPUT);
}



void loop()
{    
  r = analogRead(A0);

  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Voltage:");
  lcd.setCursor(8, 0);
  lcd.print(convert(exRef, r), 5);
  delay(1000);   
}

float convert(float exref, int r)
{
  return (((float) r / 1023.) * exref);
}


I have interfaced Arduino with lcd too.
I set aref to 2.5 the program and connected to lm431 circuit it was working properly.
After that I connected Arduino to lm317 circuit and set aref to 1.25. As I  connected it it was giving me maximum value 
After that I tried with normal program that is first one without using aref it was still giving me maximum value.



![lm317 circuit](https://i.stack.imgur.com/KvkNS.jpg
The minimum reference voltage (VREF) for the ATmega8A is 2.0V. Your new reference is too low for the chip.