0% found this document useful (0 votes)
11 views2 pages

Labtask Leftshift Noloop

Uploaded by

Bushra Shahzad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views2 pages

Labtask Leftshift Noloop

Uploaded by

Bushra Shahzad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

// lAB TASK # 2

// WRITE A CODE USING C PROGRAMING TO LEFT SHIFT THE VALUE STORED IN PORT 1(OF C51)
BY 1 POSITION .
//STORED VALUE IS HEXADECIMAL [Link] THIS PROGRAM ON AT89C51 to GLOW LEDS
ALTERNATELY CONNECTED TO IT 'IN THE LEFT DIRECTION'

//WITHOUT USING for LOOP

#include<reg51.h> //Header file


void delay (void);
//Declaration of a function named as delay
void delay (void) //Function with its body
{
unsigned char i; unsigned int j;
for(i=0;i<4;i++)

for(j=0;j<25500;j++);
}
void main()
{ while(1)
{
// Loading a hexadecimal number=1 in port 1 of C51 THEN then loading the
equivalent
//LEFT shifted hexnumber by 1 BIT position(from LSB to MSB)
P1=0x01; //Will glow LED connected to LSB (pin1)of
port1
delay(); //Calling the delay function to
hold glow for sometime
P1=0x02;
//Will glow LED connected to pin2 of port1
delay();
//Calling the delay function to hold glow for sometime
P1=0x04;
//Will glow LED connected to pin3 of port1
delay();
//Calling the delay function to hold glow for sometime
P1=0x08;
//Will glow LED connected to pin4 of port1
delay();
//Calling the delay function to hold glow for sometime
P1=0x10; //Will
glow LED connected to pin5 of port1
delay();
//Calling the delay function to hold glow for sometime
P1=0x20; //Will
glow LED connected to pin6 of port1
delay();
//Calling the delay function to hold glow for sometime
P1=0x40; //Will
glow LED connected to pin7 of port1
delay();
//Calling the delay function to hold glow for sometime
P1=0x80;
//Will glow LED connected to pin8(MSB) of port1
delay();
}
}

You might also like