Usb pic18f4550 :: Led toggle key

LED Toggle using Button Key


Compiler : Microchip C18 C Compiler

Kit : Bootloader USB PIC18F4550

Project : LED Toggle using Button Key


Hardware connection : COL 0 -> +5V , RD0 -> ROW 0


/*  SOURCE : WWW.ROMUX.COM
    AUTHOR : romux team     */ 
    
    
#pragma code InterruptVectorHigh = 0x2008
#pragma code InterruptVectorLow = 0x2018
#pragma code main = 0x2020

#include < p18F4550.h>
#include < delays.h>

#define key   PORTDbits.RD1   		/* PORT for key */
#define TRIS_key  TRISDbits.TRISD1    	/* TRIS for key */ 

void delay (void)
{
Delay10KTCYx(100);
}
void toggle(void)
{
    if(LATB == 0xff) 
      LATB = 0;
    else
      LATB = 0xFF;
	while(key) delay();
}
void main (void)
{
  /* Make all bits on the Port B (LEDs) output bits.
   /* If bit is cleared, then the bit is an output bit.
   */
  TRISB = 0;
  TRIS_key =1;

  while (1)
    {
	  if(key == 1) toggle();

    }
}









Post Your Comments Here :
 


User Login

Username :


Password :