Flashing LED example for a PIC18F4520

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. Here is the kit I purchased
AliExpress.com Product – PIC18F4520-I/P PIC18F4520 PIC 8-bit RISC Development Evaluation Board +14 Accessory Modules = Open18F4520 Package B

So lets flash them on and off individually

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

Code

 

[codesyntax lang=”c”]

void main()
{

TRISB = 0; // set direction to be output

do
{
LATB = 0x00; // Turn OFF LEDs on PORTB
Delay_ms(100);

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

[/codesyntax]

 

 

 

Related posts

PIC18F56Q71 MCP23008 GPIO Expander LED Examples

PIC18F56Q71 VCNL4020 Ambient Light Sensor with OLED

PIC18F56Q71 VCNL4020 Proximity Sensor with OLED

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Read More