/*
***********************************************************************************************
* 										Blinky (Hello World)
* Hardware :	PIC24-Eval-Board C
* File:			..\Blinky\Blinky.c
* Functions: 	This project is the first demo program for development board PIC24-Eval-Board C
*				with microcontroller PIC32MX360F512L mount onboard
* Date: 		4th Feb 2009
* MPLAB version:MPLAB 8.20 or above is required!
* Version:		1.0
* Programmer: 	John Leung at TechToys Co.(www.TechToys.com.hk)
*
*										Description
* This is a simple LED blinky project.
* LED0-LED3 on will blink in sequence after program compile and download.
***********************************************************************************************
*/

#include <p32xxxx.h>
#include <plib.h>

int main (void)
{
		int i;

		/* setup LED */
		mPORTDClearBits(BIT_0);/* Turn off LED0 on startup */
		mPORTDSetPinsDigitalOut(BIT_0);/* Make RD0 (LED0) as output */
		mPORTDClearBits(BIT_1);/* Turn off LED1 */
		mPORTDSetPinsDigitalOut(BIT_1);/* Make RD1 (LED1) as output */
		mPORTDClearBits(BIT_2);/* Turn off LED2 */
		mPORTDSetPinsDigitalOut(BIT_2);/* Make RD2 (LED2) as output */
		mPORTDClearBits(BIT_3);/* Turn off LED3 */
		mPORTDSetPinsDigitalOut(BIT_3);/* Make RD3 (LED3) as output */		

		while(1) // go for ever
		{
			for(i=0; i<10000; i++);// put a delay
			mPORTDToggleBits(BIT_0);/* toggle LED0 */	
			for(i=0; i<10000; i++);// put a delay
			mPORTDToggleBits(BIT_1);/* toggle LED1 */
			for(i=0; i<10000; i++);// put a delay
			mPORTDToggleBits(BIT_2);/* toggle LED2 */
			for(i=0; i<10000; i++);// put a delay
			mPORTDToggleBits(BIT_3);/* toggle LED3 */						
		};

		return 0;
}
