Working of PWM ( Pulse Width Modulation )

Pulse Width Modulation Technique is Used for sending analog signals from arduino.

You would be seeing two unfamiliar terms:

  1. Duty
  2. analogWrite()

Duty: A 25% duty cycle means that for 25% of time the signal is at its HIGH value that is 5 V and for rest of the 75% time it is at LOW value.

analogWrite(): This function is used in passing Analog Values to the Arduino Pins.

In the above Example:

  • AnalogWrite(0) means signal will always be at its low value.
  • AnalogWrite(255) means signal will always be at its HIGH value.
  • AnalogWrite(127) means that signal will be at its HIGH value for 50 % of its time.

In the duty cycle of 25 percent, it is high 25 percent of the time, and low 75 percent of the time. The frequency of this square wave, in the case of the Arduino, is about 490Hz. In other words, the signal varies between high (5V) and low (0V) about 490 times every second.

So, if you are not actually changing the voltage being delivered to an LED, why do you see it get dimmer as you lower the duty cycle? It is really a result of your eyes playing a trick on you! If the LED is switching on and off every 1ms (which is the case with a duty cycle of 50 percent), it appears to be operating at approximately half brightness because it is blinking faster than your eyes can perceive.

Therefore, your brain actually averages out the signal and tricks you into believing that the LED is operating at half brightness.

You can comment on the article below or ask a question on Uzabila QNA.

Top ↑

Sergei Ermilov

I create web projects, come up with ideas, develop, optimize and promote websites. The first steps in this direction were taken in 2008. If you have any ideas or want to suggest something, then write to me and my team.

Leave a Reply