adc pic1

In this tutorial we introduce another pheriperal of the AVR, the ADC pheriperal. The ADC has a 10 bit convertor, that means that the input voltage will be converted into values from 0 to 1023.  We read the input of an ADC channel and output it to a IO port.


The ADC has three registers that needs to be set before starting the conversion:

  • ADC Multiplexer Selection Register (ADMUX) - here you can select the ADC channel.
  • ADC Control and Status Register A (ADCSRA) - here you can select the bits that enables the ADC and starts the conversion, and the prescaler select bits.
  • ADC Data Register (ADCL and ADCH) - When an ADC conversion is complete, the result is found in these two registers.

In this example we read the value of ADC channel one and send the output to LED's on PORTD. The number of LED's that are lit correspond to the input voltage on the ADC channel.