title: Arduino UNO analogRead always returns 1023
body: <p>So my problem is as title says: Arduino UNO analogRead always returns 1023.</p>
  
  <p>But when I burn the same sketch in Arduino Mega 2650 everything works like a charm.</p>
  
  <p>I have tried to change Atmel chips on the UNO, have tried like 3 of them (ATMEGA328P-PU) and nothing changes.</p>
  
  <p>I'm trying to count signals from a hall effect sensor and display the count on a 7 segment display.</p>
  
  <p>Here is the code:</p>
  
  <pre><code>#include "SevSeg.h"
  
  SevSeg sevseg;
  volatile int rpmcount;
  
  void setup() {
    Serial.begin(9600);
    pinMode(2,INPUT_PULLUP);
    rpmcount = 0;
    sevseg.Begin(1,3,4,5,6,7,8,9,10,11,12,13);
  }
  int border=15;
  
  void loop() {
    int tmp=0;
    tmp = analogRead(0);
    if(!digitalRead(2))rpmcount=0;
    Serial.println(tmp,DEC);
    if(tmp&lt;=border &amp;&amp; res &gt;border){   
      rpmcount++;
      if(rpmcount&gt;9999)rpmcount=0;
    } 
  
    res=tmp;
    sevseg.NewNum(rpmcount,(byte) 0);
    sevseg.PrintOutput();
  }
  </code></pre>
  
  <p>Any help would be much appreciated</p>