Go Down

Topic: Mistake inPWM tutorial (Read 4067 times) previous topic - next topic

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?

Jantje

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
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 -

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy