Hey guys ! In this tutorial we will learn about Pulse Width Modulation and how arduino makes it possible.Basically, PWM is a technique or a digital mechanism to control net voltage output of certain I/O pin in arduino.In other words , it tweaks the voltage levels of a digital pin and fakes it almost like an analog pin.You might be wondering how does pwm perform this magic trick!

So, let’s explore the secret!

To understand it , you must first be familiar with the term duty cycle.

Duty  cycle is defined as the measure of that time of the TIME PERIOD of a periodic pulse for which the pulse is “high”. Usually it is expressed in percentage form.

Image result for What is duty cycle

Let’s see how our arduino brings about that cool stuff?

In normal output operation it sends stable dc voltage of 5 volts.But in this special case, instead of sending a stable dc voltage it sends a continuous pulse of a fixed time period.It is like rapidly switching the supply “on” and “off”.Consequently, what we experience is just the average of the “on” and the “off” states.But if the “on” time is greater than the “off” time, then our output voltage is more inclined towards the “on” state and vice-versa.

Let me put it this way, suppose if we set the duty cycle to 50%, then what we have is something in mid between the on and off state.So, if the output voltage was 5 volts in “on” state then we get 2.5 volts as output. Similarly,if we have 75% duty cycle , we get output as 75% of 5 volts which is equal to 3.25 volts .In arduino we have 256 possible duty cycles.This means you can access 256 different voltage levels between 0 and 5 volt from a single pwm pin.The pins available for PWM are : 3, 5, 6, 9, 10, 11.

Connect led to any of these pins and use the following instructions,

pwm=45//any value between 0 to 255.

pin =3;//any pin among 3,5,6,9,10,11

analogWrite(pin, pwm);

In robotics ,it is used to control brightness of led’s and speed of motors.

So, that’s all for Pulse width modulation.I hope you found the tutorial helpful.If you have any queries, feel free to comment it out.



Add yours

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

Powered by

Up ↑

%d bloggers like this: