user30149: I'm writing a simple application that reads voltage from analog input 0. Here is the code:
#define OUT 5
#define ADC 0

void setup() {
  ADMUX &= (0<<REFS0); //Setting reference voltage to internal 1.1V
}

// the loop routine runs over and over again forever:
void loop() {
  // read the input on analog pin 0:
  int sensorValue = analogRead(0);
  float voltage = sensorValue * (1.1 / 1023.0);
  if (voltage>0.5) {
    digitalWrite(OUT,HIGH);
  } else {
    digitalWrite(OUT,LOW);
  }
}

When I apply 1 V on ADC0, the OUT pin is low. Seems like the reference voltage is not set properly. When I set VREF to VCC (5V), everything works fine.
I cannot find the mistake. Would appreciate any help:)
Edit:
Link to datasheet: http://www.atmel.com/images/doc8008.pdf

user3917: The statement
ADMUX &= (0<<REFS0);

AND's the current value of ADMUX with zero, resulting in a zero value, and stores it into ADMUX.
To clear the REFS0 bit in ADMUX without affecting the rest of it, one generally would instead say
ADMUX &= ~(1<<REFS0);

which will AND its value with the complement of 1<<REFS0.
However, you should use the statement
analogReference(INTERNAL);

instead of setting ADMUX directly.  One of the first statements executed in the analogRead() source code is
ADMUX = (analog_reference << 6) | (pin & 0x07);

which overrides reference selections made by just changing ADMUX.
Parameters INTERNAL and DEFAULT to analogReference() select either the 1.1 V internal bandgap reference or the default analog reference, Vcc.

Edit 1:  If you replace ADMUX &= (0<<REFS0) with analogReference(INTERNAL) in setup and it still doesn't work, you will need to apply some more-powerful debugging aids.  For example, check that you got the sketch to correctly compile and that you uploaded it ok.  Check that AVCC is connected to Vcc, preferably through a low-pass filter, as noted in datasheet sections §1.1.2 and §17.9, “Analog Noise Canceling Techniques”.  Then, try several voltage inputs to see at what level the LED comes on.  If it doesn't ever come on, look for LED problems using a simple sketch like Blink.  If it comes on consistently at some input voltage, work out what reference is being applied. 

Edit 2:  Apparently the source code of analogRead() is different for ATtiny parts vs others.  The code that I see for it in ... /arduino/avr/cores/arduino/wiring_analog.c [your path may differ] is like the following (I've elided some comments and blank lines).
uint8_t analog_reference = DEFAULT;
void analogReference(uint8_t mode) {
  analog_reference = mode;
}

int analogRead(uint8_t pin) {
  #if defined( CORE_ANALOG_FIRST )
    if ( pin >= CORE_ANALOG_FIRST ) pin -= CORE_ANALOG_FIRST; // allow for channel or pin numbers
  #endif
  ADC_SetVoltageReference( analog_reference );
  ADC_SetInputChannel( pin );
  ADC_StartConversion();
  while( ADC_ConversionInProgress() );
  return( ADC_GetDataRegister() );
}

Some ADC_... functions and constants are defined in ... avr/cores/tiny/core_adc.h; and which definition of ADC_SetVoltageReference() is used depends on conditional compilation.  For a definitive check on how analogReference() is defined for your part, look for analogReference() within the assembly listing of your program.  Obtain that listing as explained in several Arduino SE answers, for example in the  “Making assembly listings” paragraph near the end of my answer to question #33033. Also, a forum.arduino.cc thread from late April 2016 has some discussion of reading ADC inputs on tinys; I don't know if it's relevant.

30149: <p>I'm writing a simple application that reads voltage from analog input 0. Here is the code:</p>

<pre><code>#define OUT 5
#define ADC 0

void setup() {
  ADMUX &amp;= (0&lt;&lt;REFS0); //Setting reference voltage to internal 1.1V
}

// the loop routine runs over and over again forever:
void loop() {
  // read the input on analog pin 0:
  int sensorValue = analogRead(0);
  float voltage = sensorValue * (1.1 / 1023.0);
  if (voltage&gt;0.5) {
    digitalWrite(OUT,HIGH);
  } else {
    digitalWrite(OUT,LOW);
  }
}
</code></pre>

<p>When I apply 1 V on ADC0, the OUT pin is low. Seems like the reference voltage is not set properly. When I set VREF to VCC (5V), everything works fine.</p>

<p>I cannot find the mistake. Would appreciate any help:)</p>

<p>Edit:</p>

<p>Link to datasheet: <a href="http://www.atmel.com/images/doc8008.pdf" rel="nofollow noreferrer">http://www.atmel.com/images/doc8008.pdf</a></p>
 3917: <p>The statement</p>

<pre><code>ADMUX &amp;= (0&lt;&lt;REFS0);
</code></pre>

<p>AND's the current value of ADMUX with zero, resulting in a zero value, and stores it into ADMUX.</p>

<p>To clear the REFS0 bit in ADMUX without affecting the rest of it, one generally would instead say</p>

<pre><code>ADMUX &amp;= ~(1&lt;&lt;REFS0);
</code></pre>

<p>which will AND its value with the complement of <code>1&lt;&lt;REFS0</code>.</p>

<p>However, you should use the statement</p>

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

<p>instead of setting ADMUX directly.  One of the first statements executed in the <a href="http://garretlab.wb.fc2.com/en/arduino/inside/arduino/wiring_analog.c/analogRead.html" rel="nofollow noreferrer"><code>analogRead()</code> source code</a> is</p>

<pre><code>ADMUX = (analog_reference &lt;&lt; 6) | (pin &amp; 0x07);
</code></pre>

<p>which overrides reference selections made by just changing ADMUX.</p>

<p>Parameters <code>INTERNAL</code> and <code>DEFAULT</code> to <a href="https://www.arduino.cc/en/Reference/AnalogReference" rel="nofollow noreferrer">analogReference()</a> select either the 1.1 V internal bandgap reference or the default analog reference, Vcc.</p>

<hr>

<p><em>Edit 1:</em>  If you replace <code>ADMUX &amp;= (0&lt;&lt;REFS0)</code> with <code>analogReference(INTERNAL)</code> in setup and it still doesn't work, you will need to apply some more-powerful debugging aids.  For example, check that you got the sketch to correctly compile and that you uploaded it ok.  Check that AVCC is connected to Vcc, preferably through a low-pass filter, as noted in datasheet sections §1.1.2 and §17.9, “Analog Noise Canceling Techniques”.  Then, try several voltage inputs to see at what level the LED comes on.  If it doesn't ever come on, look for LED problems using a simple sketch like Blink.  If it comes on consistently at some input voltage, work out what reference is being applied. </p>

<hr>

<p><em>Edit 2:</em>  Apparently the source code of <code>analogRead()</code> is different for ATtiny parts vs others.  The code that I see for it in ... /arduino/avr/cores/arduino/wiring_analog.c [your path may differ] is like the following (I've elided some comments and blank lines).</p>

<pre><code>uint8_t analog_reference = DEFAULT;
void analogReference(uint8_t mode) {
  analog_reference = mode;
}

int analogRead(uint8_t pin) {
  #if defined( CORE_ANALOG_FIRST )
    if ( pin &gt;= CORE_ANALOG_FIRST ) pin -= CORE_ANALOG_FIRST; // allow for channel or pin numbers
  #endif
  ADC_SetVoltageReference( analog_reference );
  ADC_SetInputChannel( pin );
  ADC_StartConversion();
  while( ADC_ConversionInProgress() );
  return( ADC_GetDataRegister() );
}
</code></pre>

<p>Some <code>ADC_...</code> functions and constants are defined in ... avr/cores/tiny/core_adc.h; and which definition of <code>ADC_SetVoltageReference()</code> is used depends on conditional compilation.  For a definitive check on how <code>analogReference()</code> is defined for your part, look for <code>analogReference()</code> within the assembly listing of your program.  Obtain that listing as explained in several Arduino SE answers, for example in the  “Making assembly listings” paragraph near the end of <a href="https://arduino.stackexchange.com/a/33042/3917">my answer to question #33033</a>. Also, <a href="https://forum.arduino.cc/index.php?topic=299759.45" rel="nofollow noreferrer">a forum.arduino.cc thread from late April 2016</a> has some discussion of reading ADC inputs on tinys; I don't know if it's relevant.</p>
