Free Energy | searching for free energy and discussing free energy

Solid States Devices => Resonance Circuits and Systems => Topic started by: floodrod on September 09, 2022, 07:43:09 PM

Title: Arduino code for pulsing H-Bridge at exact frequencies
Post by: floodrod on September 09, 2022, 07:43:09 PM
I just wanted to post this in case it helps others..

Using arduino and H-bridge to flip polarities, it can be difficult to pulse DC square waves at exact controllable frequencies without complex timers, etc.  And counting delay microseconds is hit or miss..

I figured out a way to use the "Tone Function" to control frequency of pulses.  Just have to change the Hz value in the code and it's dead on..  I been playing with a resonance circuit and the frequency on the scope is exact..  Be aware- it will only work up to 31 Khz tho..

!!!!!!!!!!!!!!!!!!!!!!!!!!  CODE !!!!!!!!!!!!!!!!!!!!!!!

int r1 = 6;
int r2 = 7;
int receiver = 8;

void setup(){

   pinMode(r1, OUTPUT);
   pinMode(r2, OUTPUT);
   pinMode(receiver, INPUT);
   tone(5, 1000);


void loop() {
if (receiver == HIGH)
  digitalWrite(r1, LOW);
   digitalWrite(r2, HIGH);
digitalWrite(r1, HIGH);
digitalWrite(r2, LOW);



Now on the arduino, put a jumper from D5 to D8.   And connect your H bridge PWM inputs to pins 6 and 7.  Thats it....
To change frequency-  find this code "tone(5, 1000);"   and change 1000 to whatever hertz you want up to 31000 Hz.

Maybe someone will find this useful!  Easier than messing with 555 timers..