analogWrite - only 0 to 255

Is there a way I achieve PWM that would have more precision than only 256?

Thanks :)

use an external DAC?

Timer 1 on the Uno is a 16-bit timer so you can do it if you fiddle with the timer ports manually. You would want to choose one of the PWM modes (phase-correct or fast) and set up the ports appropriately.

There is a trade-off between resolution and frequency.

Thanks guys. Food for thought.

An example on this page:

http://www.gammon.com.au/forum/?id=11608

Example code:

#include <TimerHelpers.h>

...

  // Timer 1 - vertical sync pulses
  pinMode (vSyncPin, OUTPUT); 
  Timer1::setMode (15, Timer1::PRESCALE_1024, Timer1::CLEAR_B_ON_COMPARE);
  OCR1A = 259;  // 16666 / 64 uS = 260 (less one)
  OCR1B = 0;    // 64 / 64 uS = 1 (less one)

In this particular case the frequency was 60 Hz and the duty cycle 1 / 260. However by making OCR1A larger you could get a smaller duty cycle and thus a higher resolution (but a lower frequency). You can change the frequency to an extent by altering the prescaler.