Update: I found this, its much more elegant than what I made, kudos to you guys, Next stop a bad ass waveform generator!!
I’m in process of making a interactive LED table, for which I used IR proximity sensors, well more on that later, I needed a square wave generator, so I started out this morning with the parts and started soldering.
I planned to make it 2 channel, but I made a bit different, on one pin there is a fixed frequency of 500Hz with PWM and on other a variable frequency square wave will be generated
I ran out of DC sockets, I had a couple of usb connectors laying around so used them, also by using usb connector, I didn’t had to solder the voltage regulator.
Reset was the basic stuff, reset circuit, oscillator circuit, two potentiometers one for controlling the frequency and other to control the duty cycle of PWM wave.
The square wave is generated on pin D8 and PWM on pin D9.
It runs of atmega 8 which has about 8 seconds of boot time, I’m turning on a led just before the loop, as an indication that the two pins are now working.
It can generate frequency between 10Hz to 40KHz*.
*After experimenting I found the tone function was generating 30Hz, 122Hz, 244Hz,488Hz 978Hz,3.9KHz and 40KHz. These measurements were made on DSO nano. I’m working on a code that will directly access the registers and generate a nice sweep.
Here is the system