Ads Below The Title

Serial LEDs using 8051


connecting LEDS to P2 pins and SWITCHES to P1 pins.

#include<reg51.h>
sfr leds=0xA0;
sfr SW=0x90;
unsigned int x;
int main ()
{

while(1)
{
if(SW==0xFE)
{
      leds=
0x08 ;                       //"1000"
    for( x=0;x<20000;x++);      
// providing some random delay    
    leds=0x04;                          //"0100"
    for( x=0;x<20000;x++);
    leds=0x02;                          //"0010"
    for( x=0;x<20000;x++);
    leds=0x01;                          //"0001"
    for( x=0;x<20000;x++);
}
else if(SW==0xFD)
{   
    leds=0x01;                          //"0001"

    for( x=0;x<20000;x++);
    leds=0x02;                          //"0010"
    for( x=0;x<20000;x++);
    leds=0x04;                          //"0100"
    for( x=0;x<20000;x++);
    leds=0x08;                          //"1000"
    for( x=0;x<20000;x++);
 }
else if(SW==0xFB)
{   
    leds=0x09;                        //"1001"

    for( x=0;x<20000;x++);
    leds=0x06;                       //"0110"
    for( x=0;x<20000;x++);
  }
else if(SW==0xF7)
{
    leds=0x06;                      //"
0110"
    for( x=0;x<20000;x++);
    leds=0x09;                     //"1001"
    for( x=0;x<20000;x++);
}
else
    leds=0x00;
}
}

 
  to see output
  

Serial LEDs using 8051 Serial LEDs using 8051 Reviewed by haru on May 13, 2013 Rating: 5

No comments

Ads Inter Below The Post
Image Link [https://lh3.googleusercontent.com/-wlvSkBWGUW0/AAAAAAAAAAI/AAAAAAAAAxU/6FpWSjn-h2o/s120-c/photo.jpg] Author Name [Sora Templates] Author Description [Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard] Facebook Username [#] Twitter Username [#] GPlus Username [#] Pinterest Username [#] Instagram Username [#]