# Arduino PWM pin vs digital pin PWM simulation

Do I understand it correctly from this thread, Why do some pins have ~ signs next to their numbers?, that the PWM pins generate a square wave signal independently from what the code uploaded to the chip does after starting the PWM output? In other words, if my code contains all sorts of delay() functions that pause longer than the period of the PWM signal, the PWM signal will still be generated properly, correct?

On the other hand, if I decided to implement my own PWM on a digital pin instead by flipping the state between HIGH and LOW in my code at regular intervals, the presence of other delay() calls in other parts of the code would directly impact my ability to generate the desired consistent PWM signal. Is this correct? I hope this question makes sense (a bit hard to ask the question).

• I have a follow up question. If I used registers to flip digital port HIGH and LOW, like PORTB = 0b00000001;, will that also go through CPU as if I was using digitalWrite(1, HIGH) or would that be as efficient as using PWM port? I assume it's also inefficient, right? – pkout Jun 20 '14 at 22:30