PIC18F4520 – Interfacing LED
PIC18F4520 Mini Development Board has 3 SMD LEDs connected to port pins RB1, RB2 and RB3 via jumpers J1, J2 and J10 respectively. If any jumper is left open, then the corresponding port pin can be used independently. The sample code given below toggles the LEDs in fixed intervals. Jumpers (J1/J2/J10) have to be shorted accordingly for using the desired LED.
SchematicSample 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 39 40 41 42 43 44 45 46 |
/***************************************************************** HEADER FILES ******************************************************************/ #include<pic18.h> /***************************************************************** FUNCTION DECLARATIONS ******************************************************************/ void Delay_Ms(unsigned int); /***************************************************************** MAIN FUNCTION ******************************************************************/ void main() { TRISB = 0x00; /* PORTB configured as o/p */ while(1) { PORTB = 0xFF; /* Make port pins high to turn on LEDs */ Delay_Ms(500); /* Delay fuction called for 500ms */ PORTB = 0x00; /* Make port pins low to turn off LEDs */ Delay_Ms(500); /* Delay fuction called for 500ms */ } } /***************************************************************** * Function : Delay_Ms * * * * Description : Function for delay * * * * Parameter : ms - delay in milliseconds * ******************************************************************/ void Delay_Ms(unsigned int ms) { int i,count; for(i=1; i<=ms; i++) { count = 498; while(count != 1) { count--; } } } /*********************** END OF PROGRAM ************************/ |
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
Support
Please share your ideas with us, visit our forum for discussion
Leave a Reply
You must be logged in to post a comment.