Skip to content

Instantly share code, notes, and snippets.

@boxysean
Created December 4, 2013 19:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save boxysean/7794362 to your computer and use it in GitHub Desktop.
Save boxysean/7794362 to your computer and use it in GitHub Desktop.
why don't i get better resolution when i pwm?
#define PWM_PIN 2
#define BIT_RESOLUTION_READ 12
#define BIT_RESOLUTION_WRITE 12
void setup() {
pinMode(PWM_PIN, OUTPUT);
analogWriteResolution(BIT_RESOLUTION_WRITE);
analogReadResolution(BIT_RESOLUTION_READ);
Serial.begin(9600);
}
void loop() {
for (int i = 0; i <= 16; i++) {
analogWrite(PWM_PIN, i);
Serial.println(i);
delay(400);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment