A Power Inverter with Arduino Pulse Source

After going through some of the tutorials on Arduino’s site, I really started to appreciate what a powerful platform Arduino really is. A lot of seemingly complex software/hardware interactions can be made quite easy with relatively few components and little coding. As one of my first Arduino based projects, I built a simple power inverter driven by Arduino.

The following is the circuit diagram of this inverter. As you can see, the two MOSFETs attached to the center-tapped transformer (mine was removed from an old UPS), when driven by a rectangular or sinusoidal wave, will produce alternating current in the primary winding. The pull-down resistors (1M) are necessary to prevent any electrical noise. The 10K resistors are not strictly necessary, but I placed them there to prevent damage to the Arduino board in case of a MOSFET failure.

An Inverter using Arduino

An Inverter using Arduino

The gates of the two MOSFETS are connected to two digital pins of the Arduino board. The following code shows how to use the simple bit-banging technique to generate the 60Hz square wave needed for the inverter.

int pin1 =  4; 
int pin2 =  5; 

void setup()   {                
  pinMode(pin1, OUTPUT);     
  pinMode(pin2, OUTPUT);     

void loop()                     
  digitalWrite(pin1, HIGH);   
  digitalWrite(pin2, LOW);  
  digitalWrite(pin1, LOW);   
  digitalWrite(pin2, HIGH);    

The benefit of using an Arduino to control the waveform generation is that the output frequency can be precisely controlled. Of course, if the output waveform accuracy is a concern, more advanced PWM signal with a 50% duty cycle should be used to drive the MOSFETs. An inverter gate would be necessary in this case to obtain the opposite phase pulse signal to drive the second MOSFET. We can even use Arduino to generate pure sinusoidal wave to drive this inverter.

In my example above, the gate-to-source voltage comes directly from the TTL output of the Arduino digital pin. This voltage is acceptable for a 12V Vcc. If the circuit requires higher DC voltage, the gate-to source-voltage may need to be amplified for the MOSFETS to switch properly. The optimal driven voltage can be found on the datasheet of the particular MOSFET used. In this case, it is RFP50N06.

Be Sociable, Share!


  1. Jack Visage says:

    The gates of the two mosfets are connected to two digital pins of the arduino board.
    Then the benefit of using an Arduino to control the waveform generation is that the frequency can be precisely controlled. So that the output waveform accuracy is a concern, more advance PWM signal with a 50% duty cycle should be used to drive the MOSFETS. I got it, thanks for the info by the way.

  2. Einherjar says:

    Shouldn’t the delay on lines 13 & 16 be 8ms (62.5Hz) not 7ms (71.4Hz)?

    • kwong says:

      The total delay should be around 8ms. Since the instructions take some time to execute, the total time delay is actually just above 8ms in my experiment and the resulted waveform is very close to 60Hz.

      For more accurate timing, you can use the interrupt method mentioned here.

  3. bino oetomo says:

    Dear Kerry

    What if I change one of the Mosfet with a P-channel one, and just control it using single PWM pin in 50% ?

    Can it work ??


  4. Smitha says:

    IF i have four switches to be used in the inverter. Say I’m making a 3 level inverter, how do I go about it as I’m very new to Micrcontrollers.

  5. AdeZ says:

    I want to use this circuit but at 350V (300VA transformer).
    What type of transistors do I need ?


  6. tejaswi says:

    what will be the code if MOSFET’s are replaced with IGBT’s for 1KVA output?

  7. tejaswi says:

    and what should be the duty cycle?

  8. Tarik says:

    this is very good tutorial, I need to build inverter, but is posible to get 1000Hz and 20V-30V by changing transformator and delay on arduino from 7 to 0,5

  9. syafirul says:

    sir how do i generate signal from arduino to get output 240V AC

  10. […] Prototipo di Inverter 12Vdc::110Vac: INVERTER […]

  11. SANTIAGO PEREZ says:

    ¿una pregunta este circuito funciona con 24 voltios de entrada?

    ¿a question this circuit works with 24V input?

  12. Josivan says:

    Hello, mr. Kerry.

    How can i do to regulate de output AC voltage by using the internal comparator of the Arduino?

    Because, when i get a well charged battery, the voltage is 13 Volts and my output grows up to 150V

    Can you help me with this problem on the code and suggest the eletrical modifications to the schematic, please?

  13. tiago says:

    how to generate sine wave 60hz? give examples!!!!!!

Leave a Reply