You are on page 1of 1

/* Incrementing LED's on PORT B */

/* Mike Lawrence Feb 2004 */


void delay(void)
{
unsigned int count ; /*declare a variable for the delay*/
for ( count = 0 ; count <= 32000 ; count= count + 1) ;
}

void main (void)


{
unsigned int value = 0; /*declare & initialise variable for increment*/

/* Select the Register bank 1 */


set_bit ( STATUS, RP0 ) ;
/* set all of PORTB for output */
TRISB = 0x00 ;
/* set all of PORTA for input */
TRISA = 0x1f ;
/* now use Register bank 0 */
clear_bit ( STATUS, RP0 ) ;

while (1) {
/* send the LED bit pattern to PORT B LEDS */
PORTB = value;
/*delay*/
delay();
/*increase the value of the increment by one */
value= value + 1;
/*check if the value is less than 255 (hex ff)*/
if(value == 0xff)
/*reset the variable if value is at max limit*/
{value = 0;}
}
}

You might also like