500VDC power supply circuit?

I ment a flash, the one for a camera : Flash (photography) - Wikipedia
A transformer is used to make a few hundreds of volts from 3V batteries.

Since I used the Arduino with TIMER1 to drive the transformer (not directly, but with transistors), I let the Arduino make a frequency sweep and I measured the high voltage after a rectifier. Later I added a series capacitor to the primary side of the transformer. A capacitor of 100nF worked best for the transformer I have.

Working with high voltages could be dangerous. If you solder something badly, the high voltage could turn up everywhere in your circuit. I wrote my own code for the TIMER1, since I don't know if the tone() function is able to get to 50kHz.

As you can see in the schematic, I used a lot 1N4148 diodes for protection. The Arduino is also used for other things, and I don't trust my circuit that well with very high voltages. I also use a full bridge rectifier, just because I liked to do that. Reading the analog voltage was very noisy, so I added a capacitor of 1nF (C10), and I use the average a few samples in my sketch. The 2*22M draw current from the high voltage, and I had to find the new resonance frequency.