Created
November 12, 2014 18:30
-
-
Save 1905/7153b0f50d6d86ae2cf2 to your computer and use it in GitHub Desktop.
Arduino ADC increase to 10-16 bit
This file contains hidden or 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
#define potPin 0 | |
#define ledPin 9 | |
int potVal; | |
void setup() | |
{ | |
/**********************************************************************************/ | |
// Set pwm clock divider | |
/**********************************************************************************/ | |
TCCR1B &= ~(1 << CS12); | |
TCCR1B |= (1 << CS11); | |
TCCR1B &= ~(1 << CS10); | |
/**********************************************************************************/ | |
// Set pwm resolution to mode 7 (10 bit) | |
/**********************************************************************************/ | |
TCCR1B &= ~(1 << WGM13); // Timer B clear bit 4 | |
TCCR1B |= (1 << WGM12); // set bit 3 | |
TCCR1A |= (1 << WGM11); // Timer A set bit 1 | |
TCCR1A |= (1 << WGM10); // set bit 0 | |
pinMode(ledPin, OUTPUT); | |
} | |
void loop() | |
{ | |
potVal = analogRead(potPin); | |
analogWrite(ledPin, potVal); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment