How do you output whole number voltages (1-4V) from an Arduino/5V source using only digital pins and passive components?
simulate this circuit &ndash; Schematic created using CircuitLab

As the gentleman in your comment mention, you can use a pwm output the voltage you want. Let's say you let it switch at 1kHz and you want 4V.

In that 1ms, on 0.8ms and off 0.2ms. You would get close to 4V.