First undertaking is about the utilization of LEDs use in PIC microcontroller utilizing C language Program.
Program (mplab)
#include <xc.h>
#include <pic18f458.h>
#define LED PORTC
void main(void)
{
TRISC=0;
PORTC=00;
LED=0;
for(;;)
{
PORTC++;
LED++;
}
return;
}
Output on proteus simulation
Write a C18 Program to toggle all bits of PORTB continuously with a delay of 250 ms.
Program (mplab)
#include <xc.h>
#include <pic18f458.h>
void MSDelay(unsigned int);
void main(void)
{
TRISC=0;
while(1)
{
PORTC=0x55;
MSDelay(250);
PORTC=0xAA;
MSDelay(250);
return;
}
}
void MSDelay(unsigned int itime)
{
unsigned int i;
unsigned int j;
for(i=0; i < itime; i++)
for(j=0; j < 165; j++);
}
Output on proteus simulation
0 Comments