Interfacing Buzzer With AVR ATmega16 (Mini Development Board)
AVR ATmega16 Mini Development Board has an on-board buzzer connected to port pin PC7 via jumper J12. To use the buzzer, it is necessary to short the jumper. If PC7 is to be used for any other purpose, then the jumper should be left open.
Sample code to test the on-board buzzer is given below. As per the code given below, when the switch SW1 is pressed, it generates interrupt and toggles the status of buzzer.
Note: To use buzzer, don’t forget to short jumper J12. Leaving it open frees PC7 and it can be used for any other desired purpose.
Schematic
Sample Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
/******************************************************** HEADER FILES *********************************************************/ #include<avr/io.h> #include<avr/interrupt.h> /******************************************************** MAIN FUNCTION *********************************************************/ int main() { DDRC |= 0X80; /* PC7 configured as output */ DDRD &= 0XFC; /* PD2 PD3 configured as input */ SREG = 0X80; /* Global Interrupt Enable */ MCUCR = 0X0F; /* Rising edge generates interrupt */ GICR = 0XC0; /* INT0 INT1 activated */ while(1); } /******************************************************** INTERRUPT SERVICE ROUTINE *********************************************************/ ISR(_VECTOR(1)) /* External Interrupt Request 0 */ { GIFR = 0XC0; /* Interrupt Flag Clear */ PORTC ^= (0x80); } /******************* END OF PROGRAM *******************/ |
Topics related to AVR ATmega16 Mini Development Board
- AVR ATmega16 Mini Development Board – Overview
- AVR ATmega16 Mini Development Board - Interfacing LED
- AVR ATmega16 Mini Development Board – Interfacing LCD
- AVR ATmega16 Mini Development Board – Serial communication(USART)
- AVR ATmega16 Mini Development Board – Interfacing Switch
- AVR ATmega16 Mini Development Board – Interfacing Buzzer
- AVR ATmega16 Mini Development Board - Interfacing POT(ADC)
- AVR ATmega16 Mini Development Board – Interfacing Temperature sensor
- AVR ATmega16 Mini Development Board – Interfacing Servo Motor
- AVR ATmega16 Mini Development Board – Interfacing μRFID
Resources
How to buy?
- Click here to buy rhydoLABZ AVR ATmega16 Development Board-Mini
- Click here to buy rhydoLABZ AVR ATmega32 Development Board-Mini
SupportPlease share your ideas with us, visit our forum for discussion