Skip to content

Instantly share code, notes, and snippets.

@1905
Created November 12, 2014 18:30
Show Gist options
  • Save 1905/7153b0f50d6d86ae2cf2 to your computer and use it in GitHub Desktop.
Save 1905/7153b0f50d6d86ae2cf2 to your computer and use it in GitHub Desktop.
Arduino ADC increase to 10-16 bit
#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