Creating my own PWM

gilmaor:
Thanks!!

I removed the serial read, and used a voltmeter to meassure the ouput, I got close results, Which I guess are dur to Voltage lost in the capacitor.

The analogRead() also takes time. You should compensate for it.