Guest User

Untitled

a guest
Dec 13th, 2017
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. byte backup = ADMUX; // store the arduino settings
  2. ADMUX = _BV(REFS1) | _BV(MUX3) | _BV(MUX0); // internal 1.1V reference, differential: ADC1+ ADC0-, gain: 10x
  3. ADCSRA |= _BV(ADSC); // start conversion
  4.  
  5. while ((ADCSRA & _BV(ADSC)) != 0); // wait for conversion end (ADSC is cleared after the end by hardware)
  6.  
  7. int val = ADC; // read the result
  8. ADMUX = backup; // restore original settings (from arduino)
Add Comment
Please, Sign In to add comment