Created
March 31, 2017 08:39
-
-
Save ryo1kato/e644f316af0301490fb79494189fe394 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int analogReadPS(uint8_t pin) { | |
ACSR &= ~ _BV(ACD); // Enablethe analog comparator | |
bitClear(PRR, PRADC); // power up ADC | |
ADCSRA |= _BV(ADEN); | |
unsigned int reading = analogRead(pin); | |
ADCSRA &= ~_BV(ADEN); | |
bitSet(PRR, PRADC); // power down ADC | |
ACSR |= _BV(ACD); //Disable the analog comparator | |
return reading; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment