Home PICPIC Code Flashing LED example for a PIC18F4520

Flashing LED example for a PIC18F4520

by iainhendry71

This is a simple ‘Hello world’ type example. This was to test out a PIc18F4520 development board that I purchased, the board comes with 8 LED’s connected to PORT B.

So lets flash them on and off

The compiler I used was the mikroC PRO in this example, there is a nice free but limited downlopad available. It has a nice IDE and is easy to get started with, I created my hex file and uploaded this using a PicKIt3. More on the setup will come at a later date


void main()

TRISB = 0; // set direction to be output

LATB = 0x00; // Turn OFF LEDs on PORTB

LATB = 0xFF; // Turn ON LEDs on PORTB
while(1); // Endless loop



You may also like