Faking PWM on non-PWM pins


so thinking how pwm via analogwrite works putting out square wave varies in duty cycle 0 = 0% , 255 = 100%

how different 2 digitalwrite functions appropriate delaymicroseconds?
uno has pins (not 5 , 6) running 490hz (490 cycles per second), means it's 1 cycle per 2040microseconds.

what, then, difference in outcome between:

analogwrite(3, 128); 50% duty cycle, meaning every 2040microsecond period, it's on half , off other half

and

digitalwrite(3, high);
delaymicroseconds(1020);
digitalwrite(3, low);
delaymicroseconds(1020);

it not different. however, pwm pins can other things... doing way if read inputs, serial print or whatever, timing of pwm distorted.


Arduino Forum > Using Arduino > Programming Questions > Faking PWM on non-PWM pins


arduino

Comments

Popular posts from this blog

Error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode - Raspberry Pi Forums

class MPU6050 has no member named begin

missing filename after '-o'