/*****************************************************

		 PIC DEVELOPMENT BOARD
		***********************

SAMPLE #1
	A simple program to blink on-board led of
	PIC Development Board. When the BUTTON is pressed
	the speed of LED blinking fast.

	Please short JUMPER J5

Copyrights 2009 © eXtreme Electronics, India
www.eXtremeElectronics.co.in

*****************************************************/
#include <htc.h>

//Chip Settings
__CONFIG(1,0x0F24);
__CONFIG(2,0X0000);
__CONFIG(3,0X8100);
__CONFIG(4,0X0081);


//Simple Delay function
void Wait(unsigned char delay)
{
	unsigned char i;
	for(i=0;i<delay;i++)
		_delay(60000);	
}

void main()
{
	unsigned char delay=100;

	//Initialize PORTB
	//RB1 as Output (LED) rest PINs are Input.
	TRISB=0b11111101;

	//Now loop forever
	while(1)
	{
		//Check Button State
		//PORTB BIT 4 (RB4)
		if(PORTB & (0b00010000))
		{
			//Button Not Pressed
			delay = 100;

		}
		else
		{
			//Button Pressed
			delay = 15;
		}

		LATB=0B00000010;	//PORTB1 = HIGH
		Wait(delay);

		LATB=0B00000000;	//PORTB1 = LOW
		Wait(delay);
			
	}
}
