Arduino MOSFET capacitor bank controller

I am trying to use a Arduino to make a capacitor bank controller, I am using two MOSFETS, one with the collector connected to the output of the capacitor bank and the drain is the output. The other capacitor is used as a switch to avoid shorting the power supply. The capacitor bank is a 1 farad capacitor bank.
the Mosfet bases are connected to the arduino running my sketch.

Here is my code:
void setup () {
pinMode (MOSFETa, OUTPUT);
pinMode (MOSFETa1, OUTPUT);
pinMode (MOSFETb, OUTPUT);
pinMode (MOSFETb1, OUTPUT);

void loop () {

double oscillate() {
digitalWrite (MOSFETa, HIGH);
digitalWrite (MOSFETa1, HIGH);
delay (delayPeriod);
digitalWrite (MOSFETa, LOW);
digitalWrite (MOSFETa1, LOW);
delay (1);
digitalWrite (MOSFETb, HIGH);
digitalWrite (MOSFETb1, HIGH);
delay (delayPeriod);

double Clear() {
digitalWrite (MOSFETa, LOW);
digitalWrite (MOSFETa1, LOW);
digitalWrite (MOSFETb, LOW);
digitalWrite (MOSFETb1, LOW);

return 0;


Please read the sticky post, “How to use this forum - please read,” posted at or near the top of the topic listing for each section of the forum. In particular, please read the part that describes how to post code using “code” tags. Without “code” tags, your code may be garbled, as the forum’s display software tries to interpret character sequences in the code as display directives.

I have some trouble interpreting your post:

  • I don’t see a question. Is there something you want help with?
  • I’m not sure what you mean by, “capacitor controller.” When I google that phrase, I find devices that are intended for switching capacitor banks to control VAR flow on power systems. I don’ t think that’s what you’re doing here. What’s a “capacitor controller,” in this context?
  • The term, “collector,” doesn’t apply to a MOSFET. It’s not clear how things are connected. I think that a schematic diagram would be better than anything you could say about your circuit. Can you post one?
  • You mention a capacitor “used as a switch.” I don’t know what that means. Can you clarify?
  • Your code is incomplete. Some definitions of constants are certainly missing. There may be other things - maybe important things - missing, too. Can you post something that illustrates the problem - if there is a problem - and compiles?

If you’ll provide that information, maybe we can help.

[Edit: fix formatting]

I think I can guess what you mean, but its hard to be sure without a diagram.
Please read your posting for typos before posting, saying capacitor when you
mean MOSFET isn’t helping…


Can you please post a complete copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?
Include the arduino and power supply and load that you are discharging the caps to.

Can you please post a copy of your sketch, using code tags?
They are made with the </> icon in the reply Menu.
See section 7,148850.0.html

MOSFETs have Gate, Drain and Source terminals

Tom… :slight_smile: