Audio Tone Generator using AVR Microcontroller

The circuit presented here demonstrates how to generate Audible Frequency from an AVR Microcontroller. The output of Microcontroller is always digital so to generate audible sound at the outset first it needs to be converted into Analog. A DAC (Digital to Analog Converter) is used for this purpose. Microcontroller generates sine wave of Audible Frequency using DAC. This sine wave is further given to Audio Amplifier that drives speaker. Microcontroller generates sine wave of fix frequency continuously. So we can hear an audible tone of fix frequency.
Audio Tone Generator using AVR Microcontroller
The photograph given below shows the circuit is built on general purpose PCB and bread board.
As shown in figure the major building blocks are AVR Microcontroller ATMega32, 8-bit DAC DAC0808, OP-AMP LM741 and Audio Amplifier TDA7056
AVR Microcontroller
AVR Microcontroller gives Digital values to DAC to generate sine wave output through it.
It converts digital values given by ATMega32 into Analog and generates continuous type sine wave
Audio Tone Generator using AVR Microcontroller schematic
DAC0808 gives output in form of current. OP-AMP works as I to V converter and converts it in to voltage
Audio Amplifier
Audio Amplifier amplifies the signal given by OP-AMP so that it can drive speaker and generates sound output of around 1W to 3W

Circuit & Programming Description

Circuit Description

As shown in Circuit Diagram, PORTC pins PC0 ‚Äď PC7 of ATMega32 are connected to digital inputs D0-D7 of DAC0808 respectively.

8Vref+ pin (14) of DAC0808 is connected to 5V through 5 K resistor that will generate Iref of 1 mA.

Vref- pin (13) is connected to ground through another 5K resistor.

The current output pin (4) of DAC is connected to non inverting input pin (3) of op-amp LM741. Inverting terminal of op-amp is grounded. A 5 K resistor is connected between Input and Output of op-amp as shown. Output of op-amp is given to input of Audio Amplifier through 5 K pot. Pot works as volume control. Audio Amplifier TDA7056 does not require any external components.

An 8 Ohm speaker is connected to output terminals 6 ‚Äď 7 of TDA7056. All the chips works on 5 V so complete circuit is given power through 5 V supply.

DAC0808 needs -12 v supply for its ‚ÄďVee pin (2).

A 16 MHz crystal along with 2 capacitors of 22 pF is connected to crystal input pins of ATMega32.

Circuit Operation

Microcontroller generates sequence of Digital Data in such a manner that a sine wave of Audio Frequency is generated through DAC0808 and op-amp. The output of op-amp is not pure sine wave but its staircase type sine wave as shown in photograph below.

This sine wave is further amplified by Audio Amplifier chip. This chip drives 8? speaker and generates sound output of around 1 W.

Software Program

A software program written in C language is embedded into ATMega32 Microcontroller that will give sequence of data on PORTC to generate sine wave through DAC and op-amp. The program is edited, compiled and simulated in AVR studio software tool. Please refer the code for complete program with comments

Project Source Code



unsigned int sine_value[25] = {128,150,172,192,210,226,255,226,210,192,172,150,128,105,84,64,45,30,0,30,45,64,84,105,128};

void main()
int i;
DDRC = 0xFF;  // declare PORTC as output
PORTC = 0x00;  // clear port
while(1)   // continuously send values to PORTC
  for(i=0;i<25;i++)  // in loop
   PORTC = sine_value[i];  // send values from sine wave table
   _delay_us(15); // adjust delay to get frequency of 1 KHz


Project Video

For more detail: Audio Tone Generator using AVR Microcontroller

About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:

Leave a Comment

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

Scroll to Top