Embedded C program to Interface PIC18F with LED & blinking it using specified delay using PIC18F in MPLAB IDE

Program:

#include <xc.h>
void main(void) {
    TRISB=0;
    PORTB=128;
   
    while(1)
    {
              PORTB = 0xFF;           // All led 8bit ON 
              
              // Delay
              for(int i=0;i<5000;i++)
              for(int k=0;k<100;k++);
         
              PORTB = 0x00;           // All led 8bit OFF      
              
	      // Delay
              for(int i=0;i<5000;i++)
              for(int k=0;k<100;k++);  
    }
}

Output:



Previous
Next Post »