A couple of small changes to make it work properly with Arduino Due.

It now does work and produce seemingly valid output.