8051 rotating LEDs examples

Again using the ARm + 8051 development board

Example 1

#include<reg52.h>
void Delay(unsigned int t);
void main (void)
{

unsigned char i;
Delay(50000);

P2=0x7f;
while (1)
{
for(i=0;i<8;i++)
{
Delay(50000);
P2>>=1;
P2=P2|0x80;
}
P2=0x7f;
}
}
void Delay(unsigned int t)
{
while(–t);
}

 

 

Example 2

 

#include<reg52.h>
void Delay(unsigned int t);
void main (void)
{

unsigned char i;
Delay(50000);

P2=0x7f;
while (1)
{
for(i=0;i<8;i++)
{
Delay(50000);
P2<<=1;
P2=P2|0x80;
}
P2=0x7f;
}
}
void Delay(unsigned int t)
{
while(–t);
}

Related posts

8051 and RGB led example using the SiLabs IDE

C8051F340 flashing led example

8051 7 Segment display program written in Basic