voltage dimmer from arduino

hey guys i have some questions.im working on a project and i have problem now. i have solenoid. i want to kick with different forces or im charging capacitor but i want to use whatever i want amount of capacitor .example im charging to 400 volt but i want to use 250 volt for less shooting force.i have some ideas but i cant do it.im trying to make voltage dimmer circuit but i want to manage from arduino pwm signal how can i do that? thank you..

I would suggest you need to charge the capacitor up to the level you want, rather than decide how much of the charge to use.

You could either do it mathematically (by knowing the charge current and controlling the time), or through feedback by measuring the charge voltage and stopping the charge when it reaches the right point.

i dont want this way but thank you for suggestion

What circuit are you using to generate the 400V to charge the capacitor?

boost converter

Then the best solution is to control the boost converter to charge the capacitor to the voltage you want and no more.

Plan B;-

Leave charge circuit impact, have Arduino control discharge circuit (one mosfet and one resistor). you need 250 v then discharge until 250 v right before kick with different forces.

This is not green plan (waste energy), but work around plan.