this is a function generator with Arduino Pro Mini and few components that at power on start with a sawtooth of about 40
Hz and 5Vpp. Pressing one time the SWFUN button the output change to a triangular wave and pressing another time the button the output is a sine of always 40 Hz.

The LEDs means:

Blue = sawtooth

Red = triangular

Green = sinusoidal

The firmware of Arduino Pro Mini is here and require the library TimerOne.

Many thanks to the author of this article from which I was inspired.

At the PIN 9 of Arduino there is a square wave of about 32KHz . His duty cycle vary with a linear law from 0 to 1023 (10 bit DAC) and drop to zero immediatly in the sawtooth. In the triangular wave the d.c. vary from 0 to 1023 then from 1022 to 0 excluding odd values (see the code). In this mode the overall period of these two waveform is the same.

Finally the sine wave is obtained with the duty cycle depending from the math. sin function (his output is between -1 and 1) re-mapped into a 0-1023 range.

For all the waveforms the low-pass filter composed by a 10 KOhm resistor and a 100nF capacitor (with a cut-off frequency of 160 Hz about) extract the average value of the rectangular wave that is a linear function of the duty cycle of the 32KHz signal.

The push button, connected to the PIN 2 (with a pull-up of 10 KOhm) trigger the interrupt 0 of arduino that call the changemode function. This function set the general mode variable to set the proper waveform (in the loop function) and set the proper LED.

With this item you can test an oscilloscope and an audio amplifier to ear a very low frequency tone.

Of course this project is limited and you can add a frequency setting maybe up to some hundred Hz or 1 KHz.

Finally note that the schematic refer to an arduino pro mini type ATmega328 (5V, 16 MHz)

Step 1: Project Building

Not too much to say! You can solder the wires to arduino pro mini without mounting pins in bundle or use wires with female to female connectors if you just have an arduino fully mounted. The RAW pin accept a voltage up to 10V so a little square 9V battery can be used.

Of course to load the program into arduino you need the arduino IDE and a USB to serial (TTL) device like that showed in this page.

Have fun!

<p>Hi i4cc;</p><p>The link to download the ino is broken. Could you post another one?</p><p>Thanks a lot.</p>
<p>Adapted it for the ATMega368p chip running ardiuno uno, works great! was a good way to test and calibrate my scope! Now to 3d print a a case for it and make a few little script changes!</p><p>Great little project!</p>
<p>Can you please tell me how to include Square wave in to this project </p><p>thanks a lot</p>
Hi prudhvi001,<br>right now I 'm in train and can't test my suggestion.<br><br>Anyway if you change the instruction:<br><br>Timer1.pwm(PWMDAC1pin, i);<br><br>in the case 2 (triangle) :<br>Timer1.pwm(PWMDAC1pin, 1023);<br><br>in the first occurrence and<br>Timer1.pwm(PWMDAC1pin, 0);<br><br>in the second one you should be substitute the triangular wave into a square wave.<br><br>To add the fourth wave form at first three please wait some day to have a bit of free time. Anyway please try and tell me the result.<br>See you next days
<p>Nice work, thank you.</p>

About This Instructable




More by i4xcc:Modding a little tracking car model Function generator (arduino pro mini) 
Add instructable to: