LED count down

This is a hexadecimal counter using LEDs. It will start at 0xFF and count down 1

 

Code

#include <reg52.h>

void delay(unsigned int i);
main()
{
unsigned char Num = 0xff;

while (1)
{
P2 = Num;
delay(1000);
Num–;
}

}

 

void delay(unsigned int i)
{
unsigned char j;
for(i; i > 0; i–)
for(j = 255; j > 0; j–);

}

Related posts

8051 and RGB led example using the SiLabs IDE

C8051F340 flashing led example

8051 7 Segment display program written in Basic