0% found this document useful (0 votes)
12 views1 page

Labtask - Leftshift - With Loop

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)
12 views1 page

Labtask - Leftshift - With Loop

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)
. STORE HEXADECIMAL 01 IN PORT1.
//GLOW LEDS ALTERNATELY CONNECTED TO C51'port 1 IN THE LEFT DIRECTION

#include<reg51.h> //Header file


void delay (void);
//Declaration of a function named as delay
void delay (void) //Function with its body
{
unsigned int i,j;
for(i=0;i<2550;i++)
// aim of this function is the clear visualization of
shifting
{}
for(j=0;j<25500;j++)
{}
}
void main()
{
unsigned char i; // Declaraing a variable i of
8-bit data type
P1=0x01;
// Loading a hexadecimal number=80
in port 1 of C51
delay();
while(1) //endless loop
{
for(i=0;i<8;i++)
{
P1=P1<<1;
// shifting of a Bit=1(in binary
system)to LEFT

delay();
// Calling the delay function
}
}
}
//EMBEDDING THIS PROGRAM ON AT89C51 WILL GLOW LEDS 'ALTERNATELY' CONNECTED TO IT
'IN THE LEFT DIRECTION'

You might also like