Simple buzzer interface to AT89C2051 microcontroller:
This project shows how to interface a buzzer to microcontroller. When a push button is pressed a buzzer will on and off 30 times and then stops.
- AT89C2051 microcontroller
- Push button switch
- Capacitors: 33pF,33pF,10uF
- Resistor 8.2KΩ
A circuit diagram for interfacing buzzer to microcontroller is shown in figure below. Bit 7 of port 1 is directly connected to a small buzzer. This type of connection is possible only when the current required for the buzzer is less than 20mA. The port output is in current source mode, so that the buzzer will turn on when the output is at logic LOW. Bit 0 of port 3 is connected to the push button switch which is held at logic high by the pull up resistor.
The buzzer is initially OFF. When the push button is pressed, the buzzer is turned ON and OFF 30 times, with a one second delay between each output.