ATtiny88 ADC reference voltage setting 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 &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);
  }
}


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
In your setup section, you want to set or clear all relevant bits in admux.