user82232: Basically, my circuit contains only 1 resistor(like the basic LED circuit).
I tried to know what is the actual voltage of digitalWrite(High). I don't understand why the value of analogRead does not fix to 1023 but instead decreases when I decrease the value of the resistor. Moreover, the value comes to zero when my resistor value comes to 1 ohm. Really appreciate any helps here.

user7508: As a complement to chrisl's answer, it is worth noting that the
datasheet of the microcontroller (here the ATmega328P), under a section
named “Typical characteristics”, has a subsection named “Pin Driver
Strength”. This subsection has some typical voltage-vs-current curves
showing that:

the curves are not quite linear, although the non-linearity is small
at 5 V supply voltage
they depend strongly on temperature
near ambient temperature, the pin behavior is close to an ideal
voltage source in series with a 25 Ω resistor.

The curves go only up to 20 mA, as the behavior for higher currents
is not characterized.
From this, you can guess the voltage reading you expect. For example, if
you use a 470 Ω resistor (which is safe), the output pin resistance
and the external resistor make a voltage divider. The expected voltage
you read is
(5 V) × (470 Ω) / (470 Ω + 25 Ω) = 4.747 V

82232: <p>Basically, my circuit contains only 1 resistor(like the basic LED circuit).<a href="https://i.stack.imgur.com/iLh5h.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/iLh5h.png" alt="This is my circuit and my code" /></a></p>
<p>I tried to know what is the actual voltage of digitalWrite(High). I don't understand why the value of analogRead does not fix to 1023 but instead decreases when I decrease the value of the resistor. Moreover, the value comes to zero when my resistor value comes to 1 ohm. Really appreciate any helps here.</p>
 7508: <p>As a complement to chrisl's answer, it is worth noting that the
datasheet of the microcontroller (here the ATmega328P), under a section
named “Typical characteristics”, has a subsection named “Pin Driver
Strength”. This subsection has some typical voltage-vs-current curves
showing that:</p>
<ul>
<li>the curves are not quite linear, although the non-linearity is small
at 5 V supply voltage</li>
<li>they depend strongly on temperature</li>
<li>near ambient temperature, the pin behavior is close to an ideal
voltage source in series with a 25 Ω resistor.</li>
</ul>
<p>The curves go only up to 20 mA, as the behavior for higher currents
is not characterized.</p>
<p>From this, you can guess the voltage reading you expect. For example, if
you use a 470 Ω resistor (which is safe), the output pin resistance
and the external resistor make a voltage divider. The expected voltage
you read is</p>
<p>(5 V) × (470 Ω) / (470 Ω + 25 Ω) = 4.747 V</p>
