Home 80518051 Code 8051 rotating LEDs examples

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);
}

You may also like