Skip to content

Instantly share code, notes, and snippets.

@prasant1010
Created August 24, 2016 06:51
Show Gist options
  • Save prasant1010/1d2fa7c3ffa4abf7b18ca93c6ee131fa to your computer and use it in GitHub Desktop.
Save prasant1010/1d2fa7c3ffa4abf7b18ca93c6ee131fa to your computer and use it in GitHub Desktop.
unsigned int ADC_read(unsigned int x)
{
ADMUX|=x; //selecting cannel
ADCSRA|=(1<<ADSC); // start conversion
while(!(ADCSRA & (1<<ADIF))); // waiting for ADIF, conversion complete
ADCSRA|=(1<<ADIF); // clearing of ADIF, it is done by writing 1 to it
return (ADC);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment