PIC18F4520 – Interfacing Buzzer
In PIC18F4520 Mini Development Board we could interface buzzer by GPIO pin. Buzzer get connected at port pins RE0 via jumpers J19. If jumper is left open, then the corresponding port pin can be used independently. The sample code given below turn ON/OFF the Buzzer in a millisecond delay .
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 30 31 32 33 34 35 36 37 38 |
/*********************************************************************************** * Header File * ***********************************************************************************/ #include<pic18.h> /*********************************************************************************** Function Declerations ***********************************************************************************/ void Delay_Ms(unsigned int); /*********************************************************************************** Main Program ***********************************************************************************/ void main() { ADCON1=0X07; /* SETTING RE0 AS DIGITAL PIN */ TRISE0=0; /* SETING RE0 AS OUT PUT PIN */ while(1) { RE0=1; /* BUZZER ON */ Delay_Ms(500); /* Delay 500Ms */ RE0=0; /* BUZZER OFF */ Delay_Ms(500); /* Delay 500Ms */ } } /*********************************************************************************** DELAY IN MILLISECONDS ***********************************************************************************/ void Delay_Ms(unsigned int ms) { int i,count; for(i=1;i<=ms;i++) { count=498; while(count!=1) { count--; } } } |
Topics related to PIC18F4520 Mini Development Board
- PIC18F4520 Mini Development Board – Overview
- PIC18F4520 Mini Development Board – Interfacing LED
- PIC18F4520 Mini Development Board – Interfacing LCD
- PIC18F4520 Mini Development Board – Serial communication(USART)
- PIC18F4520 Mini Development Board – Interfacing Switch
- PIC18F4520 Mini Development Board – Interfacing Buzzer
- PIC18F4520 Mini Development Board – Interfacing POT(ADC)
- PIC18F4520 Mini Development Board – Interfacing Temperature sensor
- PIC18F4520 Mini Development Board – Interfacing Servo Motor
- PIC18F4520 Mini Development Board – Interfacing μRFID
Resources
- Datasheets
How to buy?
- Click here to buy rhydoLABZ PIC 16F877A Mini Development Board
- Click here to buy rhydoLABZ PIC 18F4520 Mini Development Board
- Click here to buy rhydoLABZ PIC 18F4550 Mini Development Board
- Click here to buy rhydoLABZ PIC 18F4580 Mini Development Board
SupportPlease share your ideas with us, visit our forum for discussion
Leave a Reply
You must be logged in to post a comment.