LED blinker (for PIC18F2550, PIC18F2455)

1 HW

To the USB programmer scheme there were added 2x LEDs and 2x resistors. LEDs are not connected same way - to demonstrate options how you could do it.

PIC18F2550 LED blinker scheme
Figure 1: PIC18F2550 LED blinker scheme

There are used pins RB6 and RB7 of PIC to control attached LEDs. In a very simple code there is same signal brought into RB6, RB7. But LED will light in opposite - when one is lighting, other one is not.

PIC18F2550 LED blinker on experiment solderless breadboard in action
Figure 2: PIC18F2550 LED blinker on experiment solderless breadboard in action


2 SW

As a starting point I have used application template compatible with another USB HID bootloader. I have modified all necessary places to change start points from 0x1100 to 0x1000 so it will work with Microchip's USB HID bootloader.

Core part of code is port definition section:

(main.c)
#define LED1     LATBbits.LATB6
#define LED2     LATBbits.LATB7

and execution part:

(main.c)
void main(void)
{
     //init TRIS
     TRISBbits.TRISB4=0;
     TRISBbits.TRISB5=0;
     TRISBbits.TRISB6=0;
     TRISBbits.TRISB7=0;
     //infinity loop
     while(1)
     {
          LED1=1;           //simple LED Blinking
          LED2=1;           //simple LED Blinking
          Delay10KTCYx(250);
          Delay10KTCYx(250);
          LED1=0;
          LED2=0;
          Delay10KTCYx(250);
          Delay10KTCYx(250);
     }
}

To compile code I have used:


3 Downloads

Archive PIC18F2550 Application template package.zip contains:



If you found these information useful, please consider to:

This will allow me to bring more interesting projects for you.