• Skip to main content
  • Skip to primary sidebar

Homemade Circuit Projects

Need circuit help? Post them in the comments! I've answered over 50,000!

Blog | Categories | About | Contact | Calculators-online
You are here: Home / Arduino Projects / Arduino Pure Sine Wave Inverter Circuit with Full Program Code

Arduino Pure Sine Wave Inverter Circuit with Full Program Code

Last Updated on May 24, 2025 by Swagatam 642 Comments

This article explains a simple pure sine wave inverter circuit using Arduino, which could be upgraded to achieve any desired power output as per the user's preference.

Circuit Operation

In the last article I have explained how to generate sine wave pulse width modulation or SPWM though Arduino, we are going to use the same Arduino board to make the proposed simple pure sine wave inverter circuit. The design is actually extremely straightforward, as shown in the following figure.

You just have to program the arduino board with the SPWM code as explained in the previous article, and hook it up with some of the external devices.

You may also want to read: H-Bridge Sine Wave Inverter Circuit

Arduino Pure Sine Wave Inverter Circuit

Pin#8 and pin#9 generate the SPWMs alternately and switch the relevant mosfets with the same SPWM pattern.

The mosfst in turn induce the transformer with high current SPWM waveform using the battery power, causing the secondary of the trafo to generate an identical waveform but at the mains AC level.

The proposed Arduino inverter circuit could be upgraded to any preferred higher wattage level, simply by upgrading the mosfets and the trafo rating accordingly, alternatively you can also convert this into a full bridge or an H-bridge sine wave inverter

Powering the Arduino Board

In the diagram the Arduino board could be seen supplied from a 7812 IC circuit, this could be built by wiring a standard 7812 IC in the following manner. The IC will ensure that the input to the Arduino never exceeds the 12V mark, although this might not be absolutely critical, unless the battery is rated over 18V.

If you have any questions regarding the above SPWM inverter circuit using a programmed Arduino, please feel free to ask them through your valuable comments.

Waveform Images for Arduino SPWM

Arduino Pure Sine Wave Inverter Circuit SPWM waveform

Image of SPWM waveform as obtained from the above Arduino inverter design (Tested and Submitted By Mr. Ainsworth Lynch)

UPDATE:

Using BJT Buffer Stage as Level Shifter

Since an Arduino board will produce a 5V output, it may not be an ideal value for driving mosfets directly.

Therefore an intermediate BJT level shifter stage may be required for raising the gate level to 12V so that the mosfets are able to operate correctly without causing unnecessary heating up of the devices,. The updated diagram (recommended) can be witnessed below:

simple Arduino sinewave inverter circuit using SPWM
The above design is the recommended one! (Just make sure to add the delay timer, as I have explained below!!).

UPDATE: Get this Improved Arduino SPWM Code

Program Code for the above Arduino Sine Wave Inverter Circuit

// By Swagatam
void setup(){
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
}
void loop(){
digitalWrite(8, HIGH);
delayMicroseconds(500);
digitalWrite(8, LOW);
delayMicroseconds(500);
digitalWrite(8, HIGH);
delayMicroseconds(750);
digitalWrite(8, LOW);
delayMicroseconds(500);
digitalWrite(8, HIGH);
delayMicroseconds(1250);
digitalWrite(8, LOW);
delayMicroseconds(500);
digitalWrite(8, HIGH);
delayMicroseconds(2000);
digitalWrite(8, LOW);
delayMicroseconds(500);
digitalWrite(8, HIGH);
delayMicroseconds(1250);
digitalWrite(8, LOW);
delayMicroseconds(500);
digitalWrite(8, HIGH);
delayMicroseconds(750);
digitalWrite(8, LOW);
delayMicroseconds(500);
digitalWrite(8, HIGH);
delayMicroseconds(500);
digitalWrite(8, LOW);
//......
digitalWrite(9, HIGH);
delayMicroseconds(500);
digitalWrite(9, LOW);
delayMicroseconds(500);
digitalWrite(9, HIGH);
delayMicroseconds(750);
digitalWrite(9, LOW);
delayMicroseconds(500);
digitalWrite(9, HIGH);
delayMicroseconds(1250);
digitalWrite(9, LOW);
delayMicroseconds(500);
digitalWrite(9, HIGH);
delayMicroseconds(2000);
digitalWrite(9, LOW);
delayMicroseconds(500);
digitalWrite(9, HIGH);
delayMicroseconds(1250);
digitalWrite(9, LOW);
delayMicroseconds(500);
digitalWrite(9, HIGH);
delayMicroseconds(750);
digitalWrite(9, LOW);
delayMicroseconds(500);
digitalWrite(9, HIGH);
delayMicroseconds(500);
digitalWrite(9, LOW);
}
//-------------------------------------//

Video Clip

Parts List

All resistors are 1/4 watt, 5% CFR

  • 10K = 4
  • 1K = 2
  • BC547 = 4nos
  • Mosfets IRF540 = 2nos
  • Arduino UNO = 1
  • Transformer = 9-0-9V/220V/120V current as per requirement.
  • Battery = 12V, Ah value as per requirement

Delay Effect

To ensure that the mosfet stages initiate with a delay during the Arduino booting or start up, you may modify left side BC547 transistors into delay ON stages, as shown below. This will safeguard the mosfets and prevent them from burning during power switch ON Arduino booting.

PLEASE TEST AND CONFIRM THE DELAY OUTPUT WITH AN LED AT THE COLLECTOR, BEFORE FINALIZING THE INVERTER.
FOR INCREASING THE DELAY YOU CAN INCREASE THE 10K VALUE TO 100K

A More Reliable Delay ON Timer

If you are not comfortable with the response of the above passive delay ON timer circuit, you can employ the following configuration using BJTs and a relay. This design is extremely reliable and will effectively protect your Arduino and the inverter from burning due to a malfunctioning delay effect.

Just add this to the above inverter configuration.

Adding an Automatic Voltage Regulator

Just like any other inverter the output from this design can rise to unsafe limits when the battery is fully charged.

To control this an automatic voltage regulator could be employed as shown below.

The BC547 collectors should be connected to the bases of the left side BC547 pair, which are connected to the Arduino via 10K resistors.

Arduino sinewave output correction automatic

For an isolated version of voltage correction circuit we can modify the above circuit with a transformer, as shown below:

Make sure to join the negative line with the battery negative

How to Setup

To set up the automatic voltage correction circuit, feed a stable 230V or 110V as per your inverter specs to the input side of the circuit.

Next, adjust the 10k preset carefully such that the red LEDs just light up. That's all, seal the preset and connect the circuit with the above Arduino board for implementing the intended automatic output voltage regulation.

The Complete Circuit Diagram

The complete diagram using the automatic voltage regulator and the delay ON timer would look like this:

You'll also like:

  • online UpS flow chartDifferent Types of UPS systems – Explained
  • atx2BupsHow to Make an ATX UPS Circuit with Charger
  • arduinoinvertercircuitHow to Interface Arduino PWM with any Inverter
  • 3000 watts3 Best Transformerless Inverter Circuits

Filed Under: Arduino Projects, Inverter Circuits Tagged With: Arduino, Full, Inverter, Pure, Sine, Wave

About Swagatam

I am an electronics engineer and doing practical hands-on work from more than 15 years now. Building real circuits, testing them and also making PCB layouts by myself. I really love doing all these things like inventing something new, designing electronics and also helping other people like hobby guys who want to make their own cool circuits at home.

And that is the main reason why I started this website homemade-circuits.com, to share different types of circuit ideas..

If you are having any kind of doubt or question related to circuits then just write down your question in the comment box below, I am like always checking, so I guarantee I will reply you for sure!

Previous Post: « Arduino SPWM Generator Circuit – Code Details and Diagram
Next Post: Arduino Frequency Meter Using 16×2 Display »

Reader Interactions

Comments

akash says:
July 19, 2025 at 3:35 am

at 12v input my output voltage is not going above 80-90volts . when I increased the input voltage around 30v my drain to source diode burned (i was using 4148 diode 😐 ) , can I use uf4007 as a flyback diode . I am using a push pull diver with pnp and npn for gate driving . I have used your gate driving method too , but my output never goes over 90volts . I have also tried a different transformer but same problem . not added the feedback circuit yet . can you help me please . I also tried using a 12v zener to protect the gate .

Reply
Swagatam says:
July 19, 2025 at 7:46 am

If you have used the second diagram with 4 BJTs, exactly as shown in the above article, then definitely it is the problem of your transformer.
Make sure the transformer primary is rated around 7-0-7V or 9-0-9V, and not 12-0-12V.
You can use freewheeling diodes across the transformer winding, between center tap and the outer taps. UF4007 is OK.
Please try with a 12v supply only, do not increase it.

Reply
akash says:
July 20, 2025 at 2:49 am

sir thank you for the response . sir I have tried using a 9-0-9 transformer according to you but the results are same . can you please help me with this , I have to submit this projects within a week .

Reply
Swagatam says:
July 20, 2025 at 8:23 am

Akash, that means something may be wrong either with your transformer or your meter. I think you should test it with an oscilloscope.
As you can see everything worked perfectly for my prototype. The 100 watt bulb illuminated fully, without dropping any output voltage.
Are you testing it with an output load or without load? What is the Ah rating of your battery, and current ratings of your transformer?

Reply
akash says:
July 21, 2025 at 2:08 am

sir without load i am getting 100volts and with load its dropping . I am using a 3ampere power supply . sir I have seen people using a higher ampere transformer . should I go for that ? or should I go for higher amp power supply ?

Reply
Swagatam says:
July 21, 2025 at 8:10 am

Akash, Please try the following design and let me know the results, if you still see the same problem, then certainly your transformer could be the culprit:
https://www.homemade-circuits.com/wp-content/uploads/2025/07/Arduino-sine-wave-inverter-circuit-using-TIP122-BJTs.jpg

Reply
Mia says:
May 22, 2025 at 11:24 pm

Hi Bro
Thanks for sharing your experiences.
I’m really keen to know about 3 phases and the codes.
you mean 3 phases, but with how much votage?
110V or 380V

Reply
Swagatam says:
May 23, 2025 at 8:20 am

Thanks Bro, the voltage will depend on your choice, you can feed any desired DC voltage across the MOSFETs as per the load specifications…

Reply
fadhli says:
May 16, 2025 at 9:35 am

1. anda menggunakan transformator jenis apa ? (inti besi, ferit, toroid) yang mana.
2. ideal waktu PWM berapa bagusnya ?
e-mail : fadhlyyy@yahoo.com

Reply
Swagatam says:
May 16, 2025 at 9:57 am

Iron core transformer is used in the above article.
For a ferrite core trafo you can use a pwm as high as 100kHz or above…

Reply
Anishka Prajapati says:
April 8, 2025 at 11:23 am

may you please explain the Arduino UNO code sir which used in it …….

Reply
Swagatam says:
April 8, 2025 at 5:31 pm

Hello Anishka, you can refer to the following article for the full explanation:
https://www.homemade-circuits.com/arduino-spwm-generator-circuit/

Reply
Anishka Prajapati says:
April 3, 2025 at 10:26 am

sir maybe I supply Arduino from laptop ??

Reply
Swagatam says:
April 3, 2025 at 5:55 pm

Yes, you can use the 5V from laptop USB to power your Arduino…

Reply
Anishka Prajapati says:
March 26, 2025 at 4:35 pm

sir is that IRFZ44N mosfet use kar sakte ??

Reply
Swagatam says:
March 26, 2025 at 5:21 pm

Yes, you can use IRFZ44 MOSFETs in the suggested design.

Reply
Anishka Prajapati says:
March 19, 2025 at 8:17 pm

how to make spwm from 4 mosfet in place of 2 like shown in 1st fig upto 80-100W power (please show circuit diagram or DM at my E-MAIL ID)

Reply
Swagatam says:
March 20, 2025 at 7:58 am

Do you mean a 3 phase sine wave inverter using H-bridge topology?
Yes, I am planning to write an article on this topic.
I will post it soon and let you know.

Reply
Anishka Prajapati says:
March 20, 2025 at 8:26 am

No I’m actually talking about 1 phase with H bridge and it’s really helpful if you reply it or make an article on it …. plsI appreciate it if you do

Reply
Swagatam says:
March 20, 2025 at 5:33 pm

I have created the diagram which you can see below, while in the meantime I will write the article description on this.
https://www.homemade-circuits.com/wp-content/uploads/2025/03/arduino-sine-wave-full-bridge-inverter-circuit-diagram.jpg

For the code you can use the same code which was used in the above article…

Reply
Anishka Prajapati says:
March 20, 2025 at 8:40 pm

thank you very much sir I appreciate it and it’s really helpful for me …

Reply
Swagatam says:
March 21, 2025 at 7:44 am

You are welcome Anishka,
For the complete article you can refer to the following post also:
https://www.homemade-circuits.com/arduino-h-bridge-sine-wave-inverter-circuit/

Reply
Swagatam says:
March 20, 2025 at 9:19 am

OK got it! I will post it, and let you know soon..

Reply
Anishka Prajapati says:
March 24, 2025 at 10:05 pm

Sir if I make this project then it’s necessary that I need to use bread board?
And also if I wanna increase power output then I can use transformer?
And also sir is that I can use specific separate battery for supply Arduino UNO ?

Reply
Swagatam says:
March 25, 2025 at 8:15 am

Anishka, Breadboard is not recommended for the H-bridge project, so you should try it only on a well designed PCB.
If you are using a 12V battery, then you can use a transformer as the “load” for converting 12v to 220v.
Separate battery is not required.
You can use a IC 7812 for getting the 12V supply, and IC 7805 for getting the 5V supply for the circuits from the main 12V battery.

Reply
Walker says:
March 21, 2025 at 1:36 am

Hi Sir im designing same project, i would really appreciate your assistance. I can even pay you if i have to. Please send me an email for update

Reply
Swagatam says:
March 21, 2025 at 8:44 am

Hi Walker,
No need to pay, if you have any related questions please feel free to ask, I will try my best to help you succeed with this project…

Reply
Walker says:
March 22, 2025 at 4:34 pm

I’m Designing a transformerless inverter capable of delivering 500W and output frequency of 60Hz. Beside adding DC boost converter what other changes are to made if i follow steps of your project. It’s a pure sine wave inverter like yours.

Reply
Swagatam says:
March 22, 2025 at 5:24 pm

No changes would be required in the H-bridge, you can build it exactly as shown.

Reply
Walker says:
March 22, 2025 at 5:54 pm

Meaning i will have to add DC boost code to your code and my calculated DC boost values i will obtain pure sine wave inverter delivering 500W and AC output of 60Hz?

Reply
Walker says:
March 22, 2025 at 9:11 pm

They were specific not to use a transformer that is why i chose to use DC boost converter

Swagatam says:
March 23, 2025 at 7:40 am

Then you can use the boosted DC output supply across the H-bridge MOSFET drain/source, that’s all is needed.

Swagatam says:
March 22, 2025 at 6:34 pm

For bosting the battery voltage to a higher level at 60Hz, you only need to add a transformer at the output of the H-bridge MOSFETs, meaning the “LOAD” points must be replaced with the primary of the transformer, and the secondary can be used with an AC load with boosted output.

Luca says:
March 5, 2025 at 2:14 am

Witch is the maximum output power possible with IRF540 ? I need to obatain 100VA 110V @ 400 Hz for a vintage avionic radio equipment. Thanks.

Reply
Swagatam says:
March 5, 2025 at 9:25 am

100VA, 110V, 400Hz is easily achievable using IRF540 MOSFETs, provided the transformer and the battery are also appropriately rated.

Reply
Hillary says:
September 29, 2024 at 2:55 pm

Good day sir. can lm358 OpAmp be used for the feedback circuit?

Reply
Swagatam says:
September 29, 2024 at 4:23 pm

Hi Hillary, yes any standard opamp can be used.

Reply
Ainsworth Lynch says:
July 17, 2024 at 6:04 am

Hey I built this circuit today after some years now, I keep getting one Fet blown, not sure if its because I am using Irfz44n Fets, I did not build the delay on circuit, Instead switched pin 9 and 10 to input on boot up and added a delay then switch them to output when the arduino is fully booted after 2 seconds but I still have the same fet shorting on each leg, the software method is a standard practice, I I still get output from the inverter with one fet blown 30v.

Would irf740 work better thats the only other thing I have.

Reply
Swagatam says:
July 17, 2024 at 8:43 am

Hi, In my experiment I used IRF540 and did not have any such issues. But i don’t think the IRFZ44N can be the problem, unless the MOSFET has some internal defect. You can isolate the power supply input to the transformer center-tap and the Arduino, and then switch ON the Arduino first, and then after about 5 seconds switch ON the supply to the transformer and check the results.
irf740 may not be suitable because it is rated at 400V and your transformer may be rated at just 12-0-12V.

Reply
ainsworth lynch says:
July 17, 2024 at 8:48 am

I added a software delay but when I read the article I realize the delay should just be for one Fet I delayed them both which is probably my issue.

also I used the modified spwm code that Mr Atton made im not sure if you tested that without issue also, if not I would just use your code.

Reply
Swagatam says:
July 17, 2024 at 8:56 am

Please initially check with a manual delay, by isolating the transformer center tap and the Arduino, and please use only the code supplied by me, because it is the tested one.

Reply
Jonathan codjoe says:
June 28, 2024 at 1:04 am

Hi swagatam. Trust you good?. I have designed the above circuit which is working perfectly fine. But my problem is the feedback circuit which I have designed just as it is but it is still not working. Please try and solve my problem for me. Thanks

Reply
Swagatam says:
June 28, 2024 at 8:29 am

Thank you Jonathan,
I hope you have built and implemented the following feedback circuit:
https://www.homemade-circuits.com/wp-content/uploads/2019/03/Arduino-regulation.jpg
I would suggest you to test this circuit stage separately using a variac.
In this circuit, can you please test how much voltage do you get across the 10uF capacitor.
Remember, this DC voltage across the 10uF is the direct interpretation of the AC 220V that comes from the inverter output. When the inverter output voltage rises, this DCV also rises. As soon as this corresponding DC voltage at pin#3 of the 741 IC goes above the pin#2 zener vooltage, the output pin#6 of the IC turns high causing the BC547 to conduct and ground the MOSFET gates, shutting down the inverter.
So please verify the above stage separately and let me know.

Reply
Swagatam says:
July 17, 2024 at 8:44 am

both the BJTs….

Reply
Ainsworth Lynch says:
July 17, 2024 at 6:09 am

Would I only need to pull one side to ground or both bc547

Reply
Swagatam says:
February 18, 2024 at 5:33 pm

OK, got it, thanks for the clarification.

Reply
Kerim Fahme says:
February 18, 2024 at 4:09 pm

Sorry for not being clearer. You are right, 40 years ago, MCUs didn’t exist, only CPUs did (as Z80).
I had to say on my precious post:
“In the last 40 years, I used to write first my CPU codes (for Z80), then my MCU codes (for C51 and AVR families).in assembly language only”.

Reply
Swagatam says:
February 18, 2024 at 10:37 am

MCUs existed 40 years ago? I did not know that. Thanks for sharing the info.
Sure, please feel free to share the codes anyway you like, through email or directly through comments using online free upload sites.
I appreciate your kind efforts.

Reply
Kerim Fahme says:
February 18, 2024 at 8:44 am

I asked about the SPWM frequency because lately I wrote a code for ATmega8 to generate the SPWM at 15.625 KHz (8000 KHz / 512). (For instance, since about 40 years ago, I used to write my CPU/MCU codes in assembly language only). This code can be used for a push-pull inverter which I designed its hardware too. Its push-pull transformer could be driven by two sets of N-MOSFET which, in turn, are driven by discrete circuits using BJT; NPN & PNP for fast turn on-off with dead time.
By simulating the code and its hardware, the results were as expected. I set K=0.99 in the transformer model. I hope soon I will have the time to test it in real.
In case we will find a way to let you receive files from me, I don’t mind sharing my design here (code and circuit).

Reply
Swagatam says:
February 17, 2024 at 8:37 pm

Thank you Kerim, for calculating the frequency.
According to my knowledge the only way to reduce the ripple is either by using a capacitor at the transformer output or by increasing the pwm frequency and using a ferrite core transformer.
In the above Arduino concept I used a 3uf capacitor at the output which produced a relatively good sinewave, however if this capacitor value is increased that might further help to improve the sine waveform quality and reduce the ripples proportionately, although that would also incur some power wastage. The above sinewave inverter project uses the maximum frequency for the pwm among all the published articles.

Reply
View Older Comments

Leave a Reply to Swagatam Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

circuit simulator image



Subscribe to get New Circuits in your Email



Categories

  • Arduino Projects (92)
  • Audio and Amplifier Projects (132)
  • Automation Projects (17)
  • Automobile Electronics (101)
  • Battery Charger Circuits (84)
  • Datasheets and Components (109)
  • Electronics Theory (148)
  • Free Energy (39)
  • Games and Sports Projects (11)
  • Grid and 3-Phase (19)
  • Health related Projects (25)
  • Home Electrical Circuits (12)
  • Indicator Circuits (16)
  • Inverter Circuits (94)
  • Lamps and Lights (157)
  • Meters and Testers (71)
  • Mini Projects (28)
  • Motor Controller (66)
  • Oscillator Circuits (28)
  • Pets and Pests (15)
  • Power Supply Circuits (90)
  • Remote Control Circuits (50)
  • Security and Alarm (64)
  • Sensors and Detectors (105)
  • SMPS and Converters (32)
  • Solar Controller Circuits (60)
  • Temperature Controllers (43)
  • Timer and Delay Relay (49)
  • Voltage Control and Protection (38)
  • Water Controller (36)
  • Wireless Circuits (30)





Other Links

  • Privacy Policy
  • Cookie Policy
  • Disclaimer
  • Copyright
  • Videos
  • Sitemap



People also Search

555 Circuits | 741 Circuits | LM324 Circuits | LM338 Circuits | 4017 Circuits | Ultrasonic Projects | SMPS Projects | Christmas Projects | MOSFETs | Radio Circuits | Laser Circuits | PIR Projects |

Social Profiles

  • Twitter
  • YouTube
  • Instagram
  • Pinterest
  • My Facebook-Page
  • Stack Exchange
  • Linkedin



Recent Comments

  • Swagatam on 3 Laser Beam Controlled Circuits Explored
  • ken on 8X Overunity from Joule Thief – Proven Design
  • Kim on 3 Laser Beam Controlled Circuits Explored
  • Swagatam on Making an Adjustable Electromagnet Circuit
  • Swagatam on Make this DC CDI Circuit for Motorcycles

© 2025 · Swagatam Innovations