You have no items in your shopping cart.

Subtotal: 0.00

How to Interface Buzzer with AVR Development Board

AVR Development Board

The AVR Development Board is specifically designed to help students to master the required skills in the area of embedded systems. The kit is designed in such way that all the possible features of the microcontroller will be easily used by the students. The kit supports In-system programming (ISP) which is done through Parallel/Printer port.

ATMEL’s AVR (Atmega8535), AVR Development Board Kit is proposed to smooth the progress of developing and debugging of various designs encompassing of High speed 8-bit Microcontrollers.


Piezoceramic buzzers generate sound through the bending vibrations of a thin metal plate adhered to a piezoceramic disc.

These buzzers feature a low power consumption, a safe, spark-free and non-contact structure, and a small size and light weight for an easy mounting to Printed circuit boards. As a result, an increasing number of piezoceramic buzzers are now used to generate an artificial voice in combination with voice Synthesizing ICs. To produce high-quality piezoceramic buzzers, FDK has capitalized on many years of piezoceramic production and outstanding Ceramic processing technologies and thin film forming techniques. By adding a sophisticated audio know-how to this Manufacturing expertise, FDK offers a large array of electronic tone generating products, such as piezoceramic diaphragms, sounders and buzzers, to meet loud sound outputs, wide frequency ranges, and many other requirements.

Interfacing Buzzer

Fig. 1 shows how to interface The Buzzer to microcontroller. A piezoelectric element may be driven by an oscillating electronic circuit or other audio signal source, driven with a piezoelectric audio amplifier. Sounds commonly used to indicate that a button has been pressed are a click, a ring or a beep. When the input port pin from microcontroller is changed, the sound wave is changed in Buzzer.


Interfacing Buzzer with AVR

A small piezoelectric Buzzer on the AVR Development Board Kit, by pulling pin PORTC.6 low, current will flow through the Buzzer and a relatively sharp, single-tone frequency will be heard.

The alternative Pressing of Character A or B in HyperTerminal can be used to modulate the Buzzer to oscillate around different frequencies. Then the volume of the sound will be changed by alternating the pulse width.

Pin Assignment with AVR







Turn ON BUZZ Pin of CONFIG-I switch SW5.

Connect Serial cable between USART Section in the Board and PC and open HyperTerminal

Press RESET Once (If Necessary)

Press A and B in Hyper- Terminal to turn ON andOFF the buzzer


Circuit Diagram to Interface Buzzer with AVR

Source Code

Below is the source code to interface the Buzzer with the AVR microcontroller using AVR Development Board with the help of CodeVision AVR Software.

C Program to generate sound in AVR using Buzzer


Title : Program to generate sound using buzzers





#define TXIF UCSRA.5

#define RCIF UCSRA.7

#define FOSC 16000000L

//Oscillator Frequency 16Mhz #define USART_Baud 9600

#define BaudH ((unsigned int)(((FOSC/16/USART_Baud)-1) >> 8))

#define BaudL ((unsigned int)(((FOSC/16/USART_Baud)-1) & 0xFF))

#define Buzzer PORTC.6 void Serial_init(void);

unsigned char Receive(void);

void main()


unsigned char RecDat=0;

DDRC = 0xff;

PORTC= 0x00;





RecDat = Receive();



case 'A':Buzzer=1;break;

case 'B':Buzzer=0;break;


printf("%c ",RecDat);



void Serial_init()


UCSRA = 0x00;

//Status Register UCSRB = 0x18;

//Transmit Enable,Receive

//enable,interrupts disabled UCSRC = 0x86;

//8 databits,no parity,single

//stop UBRRH = BaudH; UBRRL = BaudL; printf("\033[2J");

printf("Buzzer:\tPress 'A' to ON\n\r\tPress 'B' to OFF\n\r");


void putch(unsigned char Data)


while(TXIF==0); UDR = Data;


unsigned char Receive()



return UDR;


To compile the above C code you need the CodeVision AVR software. The software has it’s own IDE and built-in AVR gcc- Compiler. They must be properly installed and a project with correct settings must be created in order to compile the code. To compile the above code, the C file must be added to the project.

In CodeVision AVR software, you can develop or debug the project without any hardware setup. You must compile the code for generating HEX file. In debugging Mode, you want to check the port output without microcontroller Board.

The AVR Code Blaster software is used to download the hex file into your microcontroller through Parallel port.

Testing the Buzzer with AVR Development

Give +12V power supply to AVR Development Board the Buzzer is already connected with Board. Download the hex file to AVR Development .After downloading Connect the serial cable between pc and the AVR Development and set the configuration switch as per the user manual. When we press the character A in pc the Buzzer will creating some sound and Pressing B will off the sound.

General Information

    • For proper working use the components of exact values as shown in Circuit file.
    • Solder everything in a clean way. A major problem arises due to improper soldering, solder jumps and loose joints.
    • Use the exact value crystal shown in schematic.
    • More instructions are available in following articles,

User Manual for ATMEGA Development Kit

How to create & Debug a Project in CodeVision AVR.