user14669: I was thinking about if it is possible to simulate PWM (AKA pulse width modulation).
Is it possible to reach the speed of the PWM using the delay() function ?.
Note : I am talking about the pins which does not support PWM, Arduino uno Pin 13 for example.

user14942: It would be possible to do it. Would it be a smart thing to do ?
I do not think so. Micro-controllers (not just Atmel's) have dedicated hardware modules to manage the signals for PWM. What happens when you use AnalogWrite is the compiler/interpreter/whatever uses these informations to modify the appropriate registers so the toggling is not managed by the code.
If you use the delay() functions, you are simply letting clock cycles pass by until the time you set is passed which is a lot less efficient. Plus, you would probably not get the same PWM frequency.

user14953: What you are talking about is more appropriately called Bit-Banging. Check out this link. It even has an example of what you are trying to do. @Jason is correct that it causes a number of issues. The link above will also run you through the draw backs of this method which I will summarize.

Jittery due to interrupts (Interrupts can be disabled)
The Processor cannot do anything else and keep the output working
Frequency and Duty Cycle are difficult to determine


user14589: It is possible to create a PWM signal from a non-PWM digital pin although you would not want to use delay, but timer interrupts for accuracy and finite timing. PWM intervals are typically measured in (μs[microseconds] vs ms[milliseconds]).
The standard Arduino servo library  does this: Servo.

14669: <p>I was thinking about if it is possible to <strong>simulate</strong> PWM (AKA pulse width modulation).<br>
Is it possible to reach the speed of the PWM using the delay() function ?.<br>
Note : I am talking about the pins which does not support PWM, Arduino uno Pin 13 for example.</p>
 14942: <p>It would be possible to do it. Would it be a smart thing to do ?</p>

<p>I do not think so. Micro-controllers (not just Atmel's) have dedicated hardware modules to manage the signals for PWM. What happens when you use AnalogWrite is the compiler/interpreter/whatever uses these informations to modify the appropriate registers so the toggling is not managed by the code.</p>

<p>If you use the delay() functions, you are simply letting clock cycles pass by until the time you set is passed which is a lot less efficient. Plus, you would probably not get the same PWM frequency.</p>
 14953: <p>What you are talking about is more appropriately called Bit-Banging. Check out this <a href="https://www.arduino.cc/en/Tutorial/SecretsOfArduinoPWM" rel="nofollow">link</a>. It even has an example of what you are trying to do. @Jason is correct that it causes a number of issues. The link above will also run you through the draw backs of this method which I will summarize.</p>

<ul>
<li>Jittery due to interrupts (Interrupts can be disabled)</li>
<li>The Processor cannot do anything else and keep the output working</li>
<li>Frequency and Duty Cycle are difficult to determine</li>
</ul>
 14589: <p>It is possible to create a PWM signal from a non-PWM digital pin although you would not want to use delay, but timer interrupts for accuracy and finite timing. PWM intervals are typically measured in (μs[microseconds] vs ms[milliseconds]).</p>

<p>The standard Arduino servo library  does this: <a href="https://github.com/arduino/Arduino" rel="nofollow">Servo</a>.</p>
