Algorithm for simulating PWM through 595's
I am leaning now towards the first one for ease of implementation, but if the second (or some variation on it) has a nice algorithm for different values, then it might be worth looking into.


There is, and it's fairly simple.

Given a duty cycle as a rational fraction p/q between 0 and 1, do the following (pseudo-code in Javascript)

var state = 0;
// q should be a positive constant, but vary p between 0 and q
function pseudopwm(p,q)
{
   state += p;
   if (state &lt; q)
      return 0;
   state -= q;
   return 1;
}


More info in a blog entry I wrote.


  To get 16 distinct brightness levels, I need 16 times that number, right?


Sort of. The human perception of brightness is close to logarithmic, so the perceived difference between 0 and 1/16 duty cycle is huge, whereas the perceived difference between 15/16 and 16/16 duty cycle is very small.