user42134: So i've chosen to purchase a Wemos D1 R2 board in order that my old Arduino Uno R3 projects can get some new IoT features. However, even if my code is working in Uno perfectly, i want to test it using D1 before adding features. My problem is that, even if i have found tables showing differences between the 2 boards' pinouts, i cannot understand the correspondence between the pinouts. 
So i am giving you the table below. Let's say i want to define echo and trigger pins for a sensor in my code. For example:
#define TRIGGER_PIN 4
#define ECHO_PIN 3

That would be pins D3 and D4 at my Uno. But i cannot understand which those pins would be in Wemos D1 R2. Also, my two boards can be seen below for comparison



user26916: The tricky thing with the WeMos boards is the pin notation is different from other Arduino boards.
Sometimes you will see the digital pins on Arduino boards referenced with the Dn notation. For example: "Connect the HC-SR04's Trig pin to D4 on the Uno". In fact some boards such as the Nano even use the Dn pin notation on their silkscreen. This is just a way of further differentiating the pins from the An pins. You will only refer to that pin by the number 4 in your code.
The WeMos boards are different. You actually need to use D3 and D4 in your code to control the pins marked D3 and D4 on the silkscreen:
#define TRIGGER_PIN D4
#define ECHO_PIN D3

We can take a peek at the source code of the ESP8266 core for Arduino to see why:
https://github.com/esp8266/Arduino/blob/2.4.0/variants/d1_mini/pins_arduino.h#L40-L50
static const uint8_t D0   = 16;
static const uint8_t D1   = 5;
static const uint8_t D2   = 4;
static const uint8_t D3   = 0;
static const uint8_t D4   = 2;
static const uint8_t D5   = 14;
static const uint8_t D6   = 12;
static const uint8_t D7   = 13;
static const uint8_t D8   = 15;
static const uint8_t RX   = 3;
static const uint8_t TX = 1;

Now you can see that if you use your original code:
#define TRIGGER_PIN 4
#define ECHO_PIN 3

That would actually be referring to the pins marked D2 and RX on the WeMos D1 R2!

42134: <p>So i've chosen to purchase a Wemos D1 R2 board in order that my old Arduino Uno R3 projects can get some new IoT features. However, even if my code is working in Uno perfectly, i want to test it using D1 before adding features. My problem is that, even if i have found tables showing differences between the 2 boards' pinouts, i cannot understand the correspondence between the pinouts. </p>

<p>So i am giving you the table below. Let's say i want to define echo and trigger pins for a sensor in my code. For example:</p>

<pre><code>#define TRIGGER_PIN 4
#define ECHO_PIN 3
</code></pre>

<p>That would be pins D3 and D4 at my Uno. But i cannot understand which those pins would be in Wemos D1 R2. Also, my two boards can be seen below for comparison</p>

<p><a href="https://i.stack.imgur.com/ELW7g.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ELW7g.jpg" alt="enter image description here"></a></p>

<p><a href="https://i.stack.imgur.com/9Gwbj.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9Gwbj.jpg" alt="enter image description here"></a></p>
 26916: <p>The tricky thing with the WeMos boards is the pin notation is different from other Arduino boards.</p>

<p>Sometimes you will see the digital pins on Arduino boards referenced with the D<em>n</em> notation. For example: "Connect the HC-SR04's Trig pin to D4 on the Uno". In fact some boards such as the Nano even use the D<em>n</em> pin notation on their silkscreen. This is just a way of further differentiating the pins from the A<em>n</em> pins. You will only refer to that pin by the number 4 in your code.</p>

<p>The WeMos boards are different. You actually need to use <code>D3</code> and <code>D4</code> in your code to control the pins marked D3 and D4 on the silkscreen:</p>



<pre class="lang-cpp prettyprint-override"><code>#define TRIGGER_PIN D4
#define ECHO_PIN D3
</code></pre>

<p>We can take a peek at the source code of the <a href="https://github.com/esp8266/Arduino/" rel="noreferrer">ESP8266 core for Arduino</a> to see why:
<a href="https://github.com/esp8266/Arduino/blob/2.4.0/variants/d1_mini/pins_arduino.h#L40-L50" rel="noreferrer">https://github.com/esp8266/Arduino/blob/2.4.0/variants/d1_mini/pins_arduino.h#L40-L50</a></p>

<pre class="lang-cpp prettyprint-override"><code>static const uint8_t D0   = 16;
static const uint8_t D1   = 5;
static const uint8_t D2   = 4;
static const uint8_t D3   = 0;
static const uint8_t D4   = 2;
static const uint8_t D5   = 14;
static const uint8_t D6   = 12;
static const uint8_t D7   = 13;
static const uint8_t D8   = 15;
static const uint8_t RX   = 3;
static const uint8_t TX = 1;
</code></pre>

<p>Now you can see that if you use your original code:</p>

<pre class="lang-cpp prettyprint-override"><code>#define TRIGGER_PIN 4
#define ECHO_PIN 3
</code></pre>

<p>That would actually be referring to the pins marked D2 and RX on the WeMos D1 R2!</p>
