/* LED Blink: C Programming and 8051.*/
Here is a simple program to blink leds using
Embedded C.
#include<89v51reg.h>
void DeadDelay(unsigned int delay)
{
unsigned int indexI,indexJ;
for(indexI=0; indexI<1000; indexI++)
for(indexJ=0; indexJ<delay; indexJ++);
}
void main(void)
{
while (1)
{
/* Blink LED 2 */
P3_1 = 0;
DeadDelay(40);
P3_1 = 1;
DeadDelay(40);
/* Blink LED 1 */
P3_0 = 0;
DeadDelay (40);
P3_0 = 1;
DeadDelay(40);
}
}
COPYRIGHT 2009 ALL RIGHTS RESERVED
FREECPROGRAMS.COM |