<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
    <channel>
        <title>Analog vs Digital PIN assignment</title>
        <description> Hello,

How are the pins declared analog or digital?

[*EDIT* after Dust&#039;s input. What I mean is how does the FW know which physical pin to use on the board? I have two pins declared the same value, yet the FW reads the input from two different physical pins]

To keep things short and simple I will say what I am doing, and that it is working. My problem is I do not understand how it is working.

Basically I have a toggle switch connected to the X-Min Endstop pin on a RAMPS1.4 board, the pin is assigned as follows:

#define TOGGLE_SWITCH  3

Then I have a filament width sensor connected to AUX_1 peripheral, with the pin assigned as follows:


// Use the RAMPS 1.4 Analog input 3 on the AUX_1 connector
#define FILWIDTH_PIN        3 // ANALOG NUMBERING

(Note that the default is normally pin 5 on AUX_2, for my configuration I switched it to pin 3 on AUX_1.)

I have set up some basic code to change the output based on the state of the toggle switch, and when I run the FW the output of the filament width sensor is correct. Then, when I toggle the switch, the output is displayed accordingly and correctly. Which means the two pins, and their assignment, are not interfering with each other. I do not understand why not?

I know the sensor pin must be analog (input), its digital counterpart is 57 (A3 or D57), and the digital pin, well that conforms to the default configuration.

I am using this png file for the PIN verification. Please offer me any insight into this, I have been on the marlin site and github, but have found no clear indication on this distinction (between analog and digital).

Thank you.</description>
        <link>https://reprap.org/forum/read.php?415,829083,829083#msg-829083</link>
        <lastBuildDate>Sat, 06 Jun 2026 16:09:12 -0400</lastBuildDate>
        <generator>Phorum 5.2.23</generator>
        <item>
            <guid>https://reprap.org/forum/read.php?415,829083,830630#msg-830630</guid>
            <title>Re: Analog vs Digital PIN assignment</title>
            <link>https://reprap.org/forum/read.php?415,829083,830630#msg-830630</link>
            <description><![CDATA[ I dident find it eather, but the comment after the define of the analog pin makes me think it is somewher defined as an analog only pin and therefore refers maybe on fastIO only to to analog numbering]]></description>
            <dc:creator>kabelfrikkler</dc:creator>
            <category>Firmware - Marlin</category>
            <pubDate>Wed, 08 Aug 2018 18:31:34 -0400</pubDate>
        </item>
        <item>
            <guid>https://reprap.org/forum/read.php?415,829083,829158#msg-829158</guid>
            <title>Re: Analog vs Digital PIN assignment</title>
            <link>https://reprap.org/forum/read.php?415,829083,829158#msg-829158</link>
            <description><![CDATA[ Thank you for your input Dust,<br />
<br />
These two definitions/pins are used very sparingly in the firmware. I had a look at your suggestion of possible inclusion and/or exclusion via #defines and could find no evidence of that being the case.<br />
<br />
On looking at my second post I realize how absurd this seems. I define the TOGGLE_PIN to be an input and high pullup, and that is about it [in setup()]. The state of the pin is then later read and the output changed depending on the result. <br />
That is: <br />
<pre class="bbcode">    if (READ(TOGGLE_PIN)) -&gt; do something
    else -&gt; do something else</pre>
The FILWIDTH_PIN is used as default in the Marlin firmware, as when the #define FILAMENT_WIDTH_SENSOR is uncommented in the Configuration.h. The only change I made is to use a different AUX pin, 3 instead of 5.<br />
<br />
The LCD screen is updated every second. The width of the filament is being displayed and updated every second, and this works great. I also display another variable (which I made 2.0 or 5.0 for testing purposes)<br />
to display the state of the toggle switch. When the switch is toggled the display is updated accordingly, either 2.0, or 5.0, constantly....<br />
<br />
The two physical input pins are on different places on the RAMPS board -&gt; and this is the part that really confuses me. How does the FW know which physical pin to use?]]></description>
            <dc:creator>v1talogy</dc:creator>
            <category>Firmware - Marlin</category>
            <pubDate>Sat, 21 Jul 2018 04:21:05 -0400</pubDate>
        </item>
        <item>
            <guid>https://reprap.org/forum/read.php?415,829083,829141#msg-829141</guid>
            <title>Re: Analog vs Digital PIN assignment</title>
            <link>https://reprap.org/forum/read.php?415,829083,829141#msg-829141</link>
            <description><![CDATA[ the two lines are the same<br />
<br />
the code probably has a #ifdef   or #ifndef   section   that look for the defined names]]></description>
            <dc:creator>Dust</dc:creator>
            <category>Firmware - Marlin</category>
            <pubDate>Sat, 21 Jul 2018 00:17:40 -0400</pubDate>
        </item>
        <item>
            <guid>https://reprap.org/forum/read.php?415,829083,829140#msg-829140</guid>
            <title>Re: Analog vs Digital PIN assignment</title>
            <link>https://reprap.org/forum/read.php?415,829083,829140#msg-829140</link>
            <description><![CDATA[ I am asking what is the distinction between analogue and digital pins.<br />
Essentially I have this:<br />
<br />
<pre class="bbcode">
#define TOGGLE_SWITCH  3
#define FILWIDTH_PIN         3</pre>
<br />
When I "use" the TOGGLE_SWITCH in the SW it produces a different output than if I were to use the FILWIDTH_PIN <b>in the same code</b>.<br />
<br />
I do not understand how these two #defines are distinguished from one another.]]></description>
            <dc:creator>v1talogy</dc:creator>
            <category>Firmware - Marlin</category>
            <pubDate>Fri, 20 Jul 2018 22:20:25 -0400</pubDate>
        </item>
        <item>
            <guid>https://reprap.org/forum/read.php?415,829083,829139#msg-829139</guid>
            <title>Re: Analog vs Digital PIN assignment</title>
            <link>https://reprap.org/forum/read.php?415,829083,829139#msg-829139</link>
            <description><![CDATA[ If the pin can be analog or digital is part of the chip hardware <br />
<br />
not all pins can be analog, but most can be digital<br />
<br />
the naming/numbering convention is a arduino standard.    <br />
<br />
or are you just asking whats the difference?<br />
<br />
digital pins can be 0 or 5v, nothing else, ie binary  <br />
analog pins can be in 4096 voltages from 0 through to 5v]]></description>
            <dc:creator>Dust</dc:creator>
            <category>Firmware - Marlin</category>
            <pubDate>Fri, 20 Jul 2018 22:04:44 -0400</pubDate>
        </item>
        <item>
            <guid>https://reprap.org/forum/read.php?415,829083,829083#msg-829083</guid>
            <title>Analog vs Digital PIN assignment</title>
            <link>https://reprap.org/forum/read.php?415,829083,829083#msg-829083</link>
            <description><![CDATA[ Hello,<br />
<br />
How are the pins declared analog or digital?<br />
<br />
[*EDIT* after Dust's input. What I mean is how does the FW know which physical pin to use on the board? I have two pins declared the same value, yet the FW reads the input from two <b>different physical pins</b>]<br />
<br />
To keep things short and simple I will say what I am doing, and that <b>it is working</b>. My problem is I do not understand <b>how</b> it is working.<br />
<br />
Basically I have a toggle switch connected to the X-Min Endstop pin on a RAMPS1.4 board, the pin is assigned as follows:<br />
<br />
<pre class="bbcode">#define TOGGLE_SWITCH  3</pre>
<br />
Then I have a filament width sensor connected to AUX_1 peripheral, with the pin assigned as follows:<br />
<br />
<pre class="bbcode">
// Use the RAMPS 1.4 Analog input 3 on the AUX_1 connector
#define FILWIDTH_PIN        3 // ANALOG NUMBERING</pre>
<br />
(Note that the default is normally pin 5 on AUX_2, for my configuration I switched it to pin 3 on AUX_1.)<br />
<br />
I have set up some basic code to change the output based on the state of the toggle switch, and when I run the FW the output of the filament width sensor is correct. Then, when I toggle the switch, the output is displayed accordingly and correctly. Which means the two pins, and their assignment, are not interfering with each other. I do not understand why not?<br />
<br />
I know the sensor pin must be analog (input), its digital counterpart is 57 (A3 or D57), and the digital pin, well that conforms to the default configuration.<br />
<br />
I am using <a href="https://github.com/MarlinFirmware/Marlin/issues/9055" target="_blank"  rel="nofollow">this</a> png file for the PIN verification. Please offer me any insight into this, I have been on the marlin site and github, but have found no clear indication on this distinction (between analog and digital).<br />
<br />
Thank you.]]></description>
            <dc:creator>v1talogy</dc:creator>
            <category>Firmware - Marlin</category>
            <pubDate>Fri, 20 Jul 2018 10:49:29 -0400</pubDate>
        </item>
    </channel>
</rss>
