<?xml version="1.0" encoding="UTF-8"?>        <rss version="2.0"
             xmlns:atom="http://www.w3.org/2005/Atom"
             xmlns:dc="http://purl.org/dc/elements/1.1/"
             xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
             xmlns:admin="http://webns.net/mvcb/"
             xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
             xmlns:content="http://purl.org/rss/1.0/modules/content/">
        <channel>
            <title>
									analogWrite() Used on Digital Pins Instead of Analog Pins? - Programming				            </title>
            <link>https://forum.etechnophiles.com/arduino-programming/analogwrite-used-on-digital-pins-instead-of-analog-pins/</link>
            <description>Hi,
Welcome to the eTechnophiles forum. 
Got a question like, \&#039;What resistor value to choose for your simple LED project\&#039; OR \&#039;Where is the resistor connected to the inbuilt LED in Arduino UNO\&#039;s schematic\&#039; - All will be answered here. 
Feel free to check out the topics below.</description>
            <language>en-US</language>
            <lastBuildDate>Sun, 12 Apr 2026 17:20:17 +0000</lastBuildDate>
            <generator>wpForo</generator>
            <ttl>60</ttl>
							                    <item>
                        <title>RE: analogWrite() Used on Digital Pins Instead of Analog Pins?</title>
                        <link>https://forum.etechnophiles.com/arduino-programming/analogwrite-used-on-digital-pins-instead-of-analog-pins/#post-226</link>
                        <pubDate>Mon, 25 Nov 2024 05:18:03 +0000</pubDate>
                        <description><![CDATA[@catelectronics Thanks for clarifying this.]]></description>
                        <content:encoded><![CDATA[@catelectronics Thanks for clarifying this.]]></content:encoded>
						                            <category domain="https://forum.etechnophiles.com/arduino-programming/">Programming</category>                        <dc:creator>Admin</dc:creator>
                        <guid isPermaLink="true">https://forum.etechnophiles.com/arduino-programming/analogwrite-used-on-digital-pins-instead-of-analog-pins/#post-226</guid>
                    </item>
				                    <item>
                        <title>Answer to: analogWrite() Used on Digital Pins Instead of Analog Pins?</title>
                        <link>https://forum.etechnophiles.com/arduino-programming/analogwrite-used-on-digital-pins-instead-of-analog-pins/#post-217</link>
                        <pubDate>Wed, 20 Nov 2024 05:06:11 +0000</pubDate>
                        <description><![CDATA[To expand on what @ankunegi said, here’s a simple example of how analogWrite() works on a PWM pin in practice:
void setup() {
  pinMode(9, OUTPUT);  // Pin 9 supports PWM
}

void loop()...]]></description>
                        <content:encoded><![CDATA[<p>To expand on what <strong>@ankunegi</strong> said, here’s a simple example of how <code>analogWrite()</code> works on a PWM pin in practice:<br /><br /></p>
<pre contenteditable="false">void setup() {
  pinMode(9, OUTPUT);  // Pin 9 supports PWM
}

void loop() {
  analogWrite(9, 128);  // 50% duty cycle (128 out of 255)
}
</pre>
<p>This will make an LED connected to pin 9 glow at half brightness because the average voltage is 2.5V (on a 5V Arduino). If you try this on an <strong>analog pin</strong> like A0, it won’t work because analog pins are meant for input, not output.</p>
<p>It’s just a quirk of how Arduino names function. Once you get used to it, it’s not a big deal.</p>]]></content:encoded>
						                            <category domain="https://forum.etechnophiles.com/arduino-programming/">Programming</category>                        <dc:creator>catElectronics</dc:creator>
                        <guid isPermaLink="true">https://forum.etechnophiles.com/arduino-programming/analogwrite-used-on-digital-pins-instead-of-analog-pins/#post-217</guid>
                    </item>
				                    <item>
                        <title>Answer to: analogWrite() Used on Digital Pins Instead of Analog Pins?</title>
                        <link>https://forum.etechnophiles.com/arduino-programming/analogwrite-used-on-digital-pins-instead-of-analog-pins/#post-43</link>
                        <pubDate>Fri, 07 Jun 2024 03:21:49 +0000</pubDate>
                        <description><![CDATA[So, analogWrite() is indeed used to create a PWM signal, which can dim LEDs, control motor speed, etc. The name is a bit misleading because it sounds like it should be used on the analog pin...]]></description>
                        <content:encoded><![CDATA[<p>So, analogWrite() is indeed used to create a PWM signal, which can dim LEDs, control motor speed, etc. The name is a bit misleading because it sounds like it should be used on the analog pins, but it's actually meant for digital pins that support PWM.</p>
<p>So PWM or analogWrite only turns the digital pins ON and OFF at a very high frequency creating a dummy analog signal. And there are 6 digital pins on UNO that supports this behavior- with a "~" symbol next to them (like 3, 5, 6, 9, 10, 11)</p>
<p>When you use analogWrite(pin, value), you're controlling the duty cycle of the PWM signal</p>
<ol>
<li>A value of 0 means the pin is off all the time.</li>
<li>A value of 255 means the pin is on all the time.</li>
<li>Values in between control how long the pin stays on during each cycle, effectively simulating an analog voltage between 0 and 5V.</li>
</ol>
<p>So analogWrite function has nothing to do with the analog pins. The term analogWrite() was chosen to make it easier for beginners to understand that this function controls something in an analog-like way (variable output), even though it uses digital pins.</p>
<p>I hope this clears up the confusion.</p>]]></content:encoded>
						                            <category domain="https://forum.etechnophiles.com/arduino-programming/">Programming</category>                        <dc:creator>Admin</dc:creator>
                        <guid isPermaLink="true">https://forum.etechnophiles.com/arduino-programming/analogwrite-used-on-digital-pins-instead-of-analog-pins/#post-43</guid>
                    </item>
				                    <item>
                        <title>analogWrite() Used on Digital Pins Instead of Analog Pins?</title>
                        <link>https://forum.etechnophiles.com/arduino-programming/analogwrite-used-on-digital-pins-instead-of-analog-pins/#post-42</link>
                        <pubDate>Tue, 04 Jun 2024 03:34:01 +0000</pubDate>
                        <description><![CDATA[I&#039;m new to Arduino and I&#039;m a bit confused about the analogWrite() function.
From what I understand, the analogWrite() command is used to generate a PWM (Pulse Width Modulation) signal, whic...]]></description>
                        <content:encoded><![CDATA[<p>I'm new to Arduino and I'm a bit confused about the <code>analogWrite()</code> function.</p>
<p>From what I understand, the <code>analogWrite()</code> command is used to generate a PWM (Pulse Width Modulation) signal, which can be used to control devices like LEDs and motors. However, I noticed that this function is used on digital pins that support PWM, rather than the analog pins.</p>
<ol>
<li><strong>Why is the <code>analogWrite()</code> command used on PWM digital pins and not on analog pins even though the command name suggest it work for analog?</strong></li>
</ol>
<p>It would be great if someone could explain the technical reasons behind this.</p>]]></content:encoded>
						                            <category domain="https://forum.etechnophiles.com/arduino-programming/">Programming</category>                        <dc:creator>Paul</dc:creator>
                        <guid isPermaLink="true">https://forum.etechnophiles.com/arduino-programming/analogwrite-used-on-digital-pins-instead-of-analog-pins/#post-42</guid>
                    </item>
							        </channel>
        </rss>
		