Output 0V to 5V with Arduino
You're trying to do &quot;digital to analog conversion&quot; or DAC. You can do that crudely with the arduino (https://create.arduino.cc/projecthub/Arduino_Scuola/build-a-simple-dac-for-your-arduino-4c00bd or https://create.arduino.cc/projecthub/instrumentation-system/dac-8-bit-using-r-2r-ladder-964837) or you can buy an external chip (for example https://learn.adafruit.com/mcp4725-12-bit-dac-tutorial/using-with-arduino?view=all)