0

ADC not working properly in Arduino Uno

ADC autostart does not work. For example, we do "ADCSRA = 0xe2" in the program, which means, among other things, that the ADC autorun bit is enabled, but autorun does not work, the value of the ADCH register is not updated.

Code:

#define ADC_input A0

// the setup routine runs once when you press reset
void setup()
{
  // initialize serial communication at 9600 bits per second
  Serial.begin(9600);
  
  // ADC setup
  ADMUX = 0x60 - A0 + ADC_input; // ADC input, 0x60 is A0, 0x61 is A1, ...
  ADCSRA = 0xe2;
  bitWrite(ADCSRA, 5, 1); // ADATE bit for auto trigger
}

// the loop routine runs over and over again forever
void loop()
{
  int v = ADCH;
  Serial.println(v);  
  delay (500);
}

Circuit:

0 comments

Please sign in to leave a comment.