Hello World Project 8051
While we start learning 'C' the first program we write is generally known as the 'Hello world Program'. In general ANSI 'C' we write a program to echo 'Hello world' on screen but in embedded 'C' the hello world program is 'Blinking LED'.

On Off a LED connected to a port pin. It is the simplest program to start your long journey. So lets have a look...

Schematic Diagram -



/***********************************************************
Example - Blink an LED connected to PORT1_0
Note - Connect a LED at PORT1_0 and flash it at a particular interval.
Here LED is connected in sinking mode Logic1 -> LED Off
Logic0 -> LED On
************************************************************/
#include < at89x52.h> // Header file for AT89S52
void ms_delay(unsigned int time)
{
unsigned int i,j;
for(i=0;i < time;i++)
{
for(j=0;j < 1275;j++);
}
}
void main()
{
P1_0=1; // initially LED is Off
while(1==1) // Infinite Loop
{
P1_0=0; // LED On
ms_delay(1000); // Approximately 1 sec delay
P1_0=1; // LED Off
ms_delay(1000);
}
}



devesh@electroons.com
Best viewed at Firefox 1024x768 resolution