user58286: I was wondering if it is possible to create diffrent voltages by just pulsing power into a capacitor,
Im using an esp32 which can only output 3v or nothing on its GPIO pins, and i need to make it possible for it to adjust the amount of voltage without anyone touching the device, so i thought maybe you could pulse 3v into a capacitor and the capacitor would only unload what ever the pulses would give in voltages combined, so e.g. 50% 3v 50% 0v, then it gives 1.5v, i have no idea how this would work or the physics behind it
all help would be appreciated

user4143: Yes. That's basically PWM through a Low Pass Filter.
Use PWM to set the "duty cycle", which is the percentage of voltage. Then ise a low-pass filter (an inductor + capacitor, or resistor + capacitor) tuned to filter out the carrier frequency (should be around 500Hz if it's the same as an Arduino) to give you a voltage that is proportional to the duty cycle.

simulate this circuit – Schematic created using CircuitLab
That should filter at about 150Hz. The bigger the capacitor the smoother your output will be, but the slower it will be to respond to changes in the specified voltage.  Note that this is not going to give you large currents, but is fine for using as a reference voltage. To boost the current you can feed it into a voltage follower:

simulate this circuit

58286: <p>I was wondering if it is possible to create diffrent voltages by just pulsing power into a capacitor,</p>
<p>Im using an esp32 which can only output 3v or nothing on its GPIO pins, and i need to make it possible for it to adjust the amount of voltage without anyone touching the device, so i thought maybe you could pulse 3v into a capacitor and the capacitor would only unload what ever the pulses would give in voltages combined, so e.g. 50% 3v 50% 0v, then it gives 1.5v, i have no idea how this would work or the physics behind it</p>
<p>all help would be appreciated</p>
 4143: <p>Yes. That's basically PWM through a Low Pass Filter.</p>
<p>Use PWM to set the &quot;duty cycle&quot;, which is the percentage of voltage. Then ise a low-pass filter (an inductor + capacitor, or resistor + capacitor) tuned to filter out the carrier frequency (should be around 500Hz if it's the same as an Arduino) to give you a voltage that is proportional to the duty cycle.</p>

<p><img src="https://i.stack.imgur.com/xtkFI.png" alt="schematic" /></p>

<p><sup><a href="/plugins/schematics?image=http%3a%2f%2fi.stack.imgur.com%2fxtkFI.png">simulate this circuit</a> &ndash; Schematic created using <a href="https://www.circuitlab.com/" rel="nofollow">CircuitLab</a></sup></p>
<p>That should filter at about 150Hz. The bigger the capacitor the smoother your output will be, but the slower it will be to respond to changes in the specified voltage.  Note that this is not going to give you large currents, but is fine for using as a reference voltage. To boost the current you can feed it into a <em>voltage follower</em>:</p>

<p><img src="https://i.stack.imgur.com/KfZr3.png" alt="schematic" /></p>

<p><sup><a href="/plugins/schematics?image=http%3a%2f%2fi.stack.imgur.com%2fKfZr3.png">simulate this circuit</a></sup></p>
