Why is analogWrite is use on digital pins

Why we use analogWrite on digital pins why not on analog pins.

please reply.

analog value to a pin. Can be used to light a LED at varying brightnesses. After a call to analogWrite() , the pin will generate a steady rectangular wave of the specified duty cycle until the next call to analogWrite() on the same pin.

1 Like

In bolt kit, we only have digital pins(5 pins,numbered from 0,1,2,3,4).
Now we use analogWrite,because the input whatever we are taking,suppose light,temperature are all in analog form,and so valuse has to taken in analog form.This value is converted to digital form.

1 Like

thanks buddy:grinning:

Thanks buddy Preformatted text@aravindaravind400
so can we use analog pin A0 to light the LED at different brightness

Hi @djasuja2003,

I believe the function of A0 pin is to measure the voltage as demonstrated in the plant monitoring project. It cannot implicitly set itself to any specified voltage. So the answer is no, you cannot use the A0 pin to control the LED.

Hope this helps.

No, you cannot use the analog pin A0 to control the LED at different brightness since, it has the function to measure the voltage.

Keyword “analogWrite(pin_no,val)” is used to give a variable input to our output device like an LED or a buzzer for example. We can use pin A0 for analogWrite but we rather reserve it for “analogRead” purpose as A0 is the only pin the supports the purpose of reading the analog values.