In this tutorial we will see how to interface a switch and buzzer with Pic16f877a starter board.
The switch will be used to control the buzzer.
Steps
- Configure the PORT D0 as output to control the buzzer.
- Configure the PORT D2 as input to read the switch status..
- Read the switch status.
- ON/OFF the Buzzer as per switch status.
Code