Variable Frequency Arduino Generator




About: Just do things, electronics, woodwork, etc.

Hello everyone, this is project How-ToDo. Since some of you asked to show in detail my variable frequency arduino generator for high voltage power supply, here it is.

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Circuit

The circuit is very simple, Arduino nano, I2C OLED display 128 to 68 pixels, 3 transistors and three buttons, two of buttons are responsible for frequency adjustment, and the third button turns ON the output signal. It's would be good to add an optical isolation or driver with GDT but I don't have components for that. Primary coil on the transformer contain 5-10 turns with 14 gauge wire, but 20 AWG wire should be enough. Also for this circuit it is necessary to make a gap between the halves of the ferrite core, I simply put a layer of paper tape.

Step 2: Firmware

The frequency is adjustable from 30Hz to 1MHz, and since its based on built-in PWM, the higher the frequency - the greater the steps, at the end it amounts to tens of kHz, but for my purposes in the range of up to 100 kHz it's good enough.
Before uploading Firmware you need to connect these libraries:

I also added power from the battery, it's some sort of power isolation, but it's going to work fine just with LM7805.
Actually there is not much to talk about, hope you like it, see you soon!

Find me on social media:

Be the First to Share


    • Made with Math Contest

      Made with Math Contest
    • Multi-Discipline Contest

      Multi-Discipline Contest
    • Robotics Contest

      Robotics Contest

    7 Discussions


    Question 11 months ago

    From what pins I will get the frequency output?


    Question 1 year ago

    I only compiled the code for Nano. I get following -

    Sketch uses 16320 bytes (53%) of program storage space. Maximum is 30720 bytes.

    Global variables use 1607 bytes (78%) of dynamic memory, leaving 441 bytes for local variables. Maximum is 2048 bytes.

    Low memory available, stability problems may occur.

    Before uploading the code, I would like to know - Will this code have real stability problems?


    Question 1 year ago on Step 2

    Sorry, l'm looking forward to make this generator but l'm having problems with the code (Adafruit_SSD1306 library). Could you please Help me somehow?

    1 answer

    Answer 1 year ago

    Height incorrect, please fix Adafruit_SSD1306.h!???
    In Adafruit_SSD1306.h

    1. uncomment #define SSD1306_128_64
    2. comment #define SSD1306_128_32
    3. comment #define SSD1306_96_16

    In the example ssd1306_128x64_i2c

    4. add #define SSD1306_LCDHEIGHT 64

    on top of

    #if (SSD1306_LCDHEIGHT != 64)
    #error("Height incorrect, please fix Adafruit_SSD1306.h!");


    Question 1 year ago on Step 2

    the frequency can start from 1Hz???


    1 year ago

    Fantastic project!
    Could this be used as a variable frequency generator in my project?
    I need to build an inverter from 12v DC input and to output 200v AC with variable frequency between 500Hz and 3kHz upto 3amps.
    This will drive an electrolumiscent panel.
    Would love to hear your input...


    1 year ago

    great instructable . i had watched the transformer video i liked your build. awesome.