Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 3

Experiment No.

1
Aim: Write C language program to
a) Read data from port P2 and P3. Add data and display result on port P0.Glow LED connected at
port pinP1.1 if carry flag set after addition.
b) Read data from port P2 and P3. Multiply data and display result on port P0 and P1
c) Write program to read switch connected at port pin P1.0, toggle it and send to port pin P2.1

Circuit Diagram:

Fig. 1 Circuit diagram of switch interfacing with 8051(c)

Worksheet 1

1) Write C language program to continuously toggle pin P1.0 without disturbing other port

pins.
2) Write C language program to perform OR operation between port pin P1.0 and P1.1.

Display result on port pin P1.2.


3) Write C language program to read port P1, Compare content of port P1 with data 80h. If data
at port P1 is greater than 80h, make port P0=0x00 and if data at port P1 is less than or equal
to 80h, make port P0=0xFF.
4) Write a program to sense lift door switch connected at port pin P2.0.Switch on the alarm
connected at port pin P2.1 if lift door is open. Write program in C language.
5) Write a program to design a calculator which performs addition, subtraction and
multiplication. Of 2 digit. If :

Sw1
0
0
1

Sw2
0
1
0

6) Write a program to toggle the p1 port continuously with some delay


7) What is the difference between sbit and bit data type.

You might also like