8051 based LED Chasing circuit

In this blog we will learn about shifting operation by developing a LED Chasing circuit. The circuit is very simple if you have a 8051 based development board then you don’t need any other things. It should be having some LED’s on it. If the board doesn’t have any LED’s on it, then you need breadboard help.

The idea is very simple, we will be having 8 LEDs ,initially we will switch on one, then we shift by one step , i.e we will swtich off the first one and swtich on the second one and so on.

The  code will look some thing like this:

int main(){ 
P2=0x00; //initialize all the pins to 0's 
       delay(1000); //give some delay,so that we can see the changes

before the start of the second while loop, the P2 contains

1 0 0 0 0 0 0 0

after that the 1 shifts to right by 1 step  for every loop

0 1 0 0 0 0 0 0  (after completion of first iteration)

0 0 1 0 0 0 0 0  (after completion of second iteration)


0 0 0 0 0 0 0 0 at this point the 1 shifted out the register and the value becomes zero, so the inner loop exits and register initializes to 0x80 again.



Add a Comment

Your email address will not be published. Required fields are marked *