Pages: [1]   Go Down
Author Topic: Mistake inPWM tutorial  (Read 3734 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

I was going through the PWM tutorial:
http://arduino.cc/en/Tutorial/PWM

Just want to make sure, but shouldn't a 25% duty cycle be AnalogWrite(63) instead of AnalogWrite(64)?

My understand is that AnalogWrite(0) should really be 1/256th duty cycle, but the program cheats and has it be 0% duty cycle. Nevertheless that should still make 63 be 1/4th duty cycle, right?
Logged

Belgium
Offline Offline
Edison Member
*
Karma: 68
Posts: 1918
Arduino rocks; but with my plugin it can fly rocking the world ;-)
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

IMHO
AnalogWrite(x) is 100 * x / 255 % duty cycle
=>
AnalogWrite(0) is 100 * 0 / 255 % or 0% duty cycle
AnalogWrite(255) is 100 * 255 / 255 % or 100% duty cycle
AnalogWrite(63) is 100 * 63 / 255 % or 24.7% duty cycle
AnalogWrite(64) is 100 * 64 / 255 % or 25.09% duty cycle
So I think 64 maches better to 25% than 63
Best regards
Jantje
Logged

Do not PM me a question unless you are prepared to pay for consultancy.
Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -

Pages: [1]   Go Up
Jump to: