You are on page 1of 114

1602-18-737-080

Mahalaxmi Bejugam

VASAVI COLLEGE OF ENGINEERING


Department of Information Technology
Course: BE Semester: VI Section: B

Roll no: 1602-18-737-080 Name: B. Mahalaxmi Date of Submission: 20.03.2021

Name of the course: ES&IOT Lab

Experiment 1.1: Addition of two numbers


Aim: To add two numbers and store result in Accumulator
Program:
mov a, #2

mov b, #3

add a,b

end

Output:
1602-18-737-080
Mahalaxmi Bejugam

Experiment 1.2: Subtraction of two numbers


Aim: To subtract two numbers and store result in Accumulator
Program:
mov a, #3

mov b, #2

subb a,b

end

Output:
1602-18-737-080
Mahalaxmi Bejugam

Experiment 1.3: Multiplication of two numbers


Aim: To multiply two numbers and store result in Accumulator
Program:
mov a, #2

mov b, #3

mul ab

end

Output:
1602-18-737-080
Mahalaxmi Bejugam

Experiment 1.4: Division of two numbers


Aim: To divide two numbers and store result in Accumulator
Program:
mov a, #10h

mov b, #02h

div ab

end

Output:
1602-18-737-080
Mahalaxmi Bejugam

Experiment 2:Average of numbers


Aim: To compute average of numbers and store result in Accumulator
Program:
mov r0,#30h

mov r1,#05h

mov b,#05

L1: add a,@r0

inc r0

djnz r1,L1

div ab

end

Output:
1602-18-737-080
Mahalaxmi Bejugam

Experiment 3 :Block transfer of numbers


Aim: To transfer block of data from one location to another location
Program:
mov r0,#30h

mov r1,#40h

mov r2,#04

L1: mov a,@r0

mov @r1,a

inc r0

inc r1

djnz r2,L1

end

Output:
1602-18-737-080
Mahalaxmi Bejugam

Experiment 4 :Count number of even and odd numbers


Aim: To count number of even and odd numbers.
Program:
mov r2,#05h

mov r1,#30h

mov r3,#00h

mov r4,#00h

l4:mov a,@r1

RRC a

jnc l2

inc r4

sjmp l3

l2:inc r3

l3:inc r1

djnz r2,l4

end

Output:
1602-18-737-080
Mahalaxmi Bejugam

Experiment 5 :Find largest number from given numbers


Aim: To find the largest number from given set of numbers
Program:
mov r1,#30h

mov r0,#5h

mov r3,#00h

mov a,@r1

L1:inc r1

mov b,@r1

mov r3,a

subb a,b

jc L3

mov a,r3

sjmp L4

L3:mov a,b

L4:djnz r0,L1

end
1602-18-737-080
Mahalaxmi Bejugam

Output:
1602-18-737-080
Mahalaxmi Bejugam

Experiment 6 :Sorting of numbers


Aim: To sort given set of numbers
Program:
L1:mov r1,#04h

L2:mov a,r1

mov r2,a

mov r0,#30h

mov a,@r0

L3:inc r0

mov b,@r0

clr c

subb a,b

jc L4

dec r0

mov a,@r0

mov @r0,b

inc r0

mov @r0,a

L4:djnz r2,L3

djnz r1,L2

end

Output:
1602-18-737-080
Mahalaxmi Bejugam
VASAVI COLLEGE OF ENGINEERING
Department of Information Technology
Course: B.E ES&IoT Lab Roll No: 1602-18-737-080
Section: IT-B Week-2 Name: B.Mahalaxmi

Experiment 1: Port toggling


Aim: To write a program which toggles port 0 with some delay.
Program:
l1:mov a,#0ffh
mov P0,a
acall delay
mov a,00h
mov P0,a
acall delay
sjmp l1
delay:mov r5,#0fh
l3:mov r3,#0ffh
l2:djnz r3,l2
djnz r5,l3
ret
end
Output:
VASAVI COLLEGE OF ENGINEERING
Department of Information Technology
Course: B.E ES&IoT Lab Roll No: 1602-18-737-080
Section: IT-B Week-2 Name: B.Mahalaxmi

Experiment 2: Toggling Port 1.0 pin


Aim: To write a C program which toggles port1.0 with some delay.

Program:
l1:setb P1.0
acall delay
clr P1.0
acall delay
sjmp l1
delay:mov r5,#1fh
l3:mov r3,#0ffh
l2:djnz r3,l2
djnz r5,l3
ret
end

Output:
VASAVI COLLEGE OF ENGINEERING
Department of Information Technology
Course: B.E ES&IoT Lab Roll No: 1602-18-737-080
Section: IT-B Week-2 Name: B.Mahalaxmi
VASAVI COLLEGE OF ENGINEERING
Department of Information Technology
Course: B.E ES&IoT Lab Roll No: 1602-18-737-080
Section: IT-B Week-2 Name: B.Mahalaxmi

Experiment 3: Handling data of P1 with port p2.1


Aim: To write a program to handle data at p1 with help of p2.1
Program:
setb p2.1
l1:jb p2.1,l2
mov a,#00h
mov p1,a
sjmp l3
l2:mov a,#0ffh
mov p1,a
l3:sjmp l1
end
Output:
VASAVI COLLEGE OF ENGINEERING
Department of Information Technology
Course: B.E ES&IoT Lab Roll No: 1602-18-737-080
Section: IT-B Week-2 Name: B.Mahalaxmi

Experiment 4: Toggling Port 0 pins


Aim: To write a C program which toggles port 0 with some delay.
Program:
#include <reg51.h>
#define led P1
void delay (unsigned int);
void main()
{
while(1)
{
led=0xff;
delay(100);
led=0x00;
delay(100);
}
}
void delay(unsigned int time)
{
unsigned int x,y;
for(x=0;x<1000;x++)
{
for(y=0;y<time;y++)
{
}
}
}
VASAVI COLLEGE OF ENGINEERING
Department of Information Technology
Course: B.E ES&IoT Lab Roll No: 1602-18-737-080
Section: IT-B Week-2 Name: B.Mahalaxmi

Output:
VASAVI COLLEGE OF ENGINEERING
Department of Information Technology
Course: B.E ES&IoT Lab Roll No: 1602-18-737-080
Section: IT-B Week-2 Name: B.Mahalaxmi

Experiment 5: Handling data at p1 with p2


Aim: To write a C program to handle data at p1 with help of p2.1
Program:
#include <reg51.h>
sbit a=P2^1;
#define led P1
void main()
{
while(1)
{
if(a==1)
led=0XFF;
else
led=0X00;
}
}
Output:
VASAVI COLLEGE OF ENGINEERING
Department of Information Technology
Course: B.E ES&IoT Lab Roll No: 1602-18-737-080
Section: IT-B Week-2 Name: B.Mahalaxmi

Experiment 6:
Aim: To write a C program to toggle p2.1 bit
Program:
#include <reg51.h>
sbit a=P2^1;
void delay (unsigned int);
void main()
{
while(1)
{
a=01;
delay(100);
a=00;
delay(100);
}
}
void delay(unsigned int time)
{
unsigned int x,y;
for(x=0;x<1000;x++)
{
for(y=0;y<time;y++)
{
}
}
}
VASAVI COLLEGE OF ENGINEERING
Department of Information Technology
Course: B.E ES&IoT Lab Roll No: 1602-18-737-080
Section: IT-B Week-2 Name: B.Mahalaxmi

Output:
VASAVI COLLEGE OF ENGINEERING
Department of Information Technology
Course: BE Semester: VI Section: B

Roll no: 1602-18-737-080 Name: Mahalaxmi Bejugam Date of Submission: 8.04.2021

Name of the course: ES&IOT Lab

LAB-3
Experiment 1: Timer in mode 0
Aim: Write a program to generate pulse, create delay with timer0 (T0) at P1.2
operate in mode0 with frequency 2 KHz.

Program:
mov tmod ,#00h;
l1: mov tl0,#1Ah;
mov th0,#1Fh;
cpl p1.2;
setb tr0;
target:jnb tf0,target;
clr tr0;
clr tf0;
sjmp l1
end
Calculations:
time period=1/2KHz =0.5millisecond.
For the half of the clock pulse time = 0.5/2=0.25 ms
Count= 0.25 milliseconds/1.085micro seconds = 230
In mode 0 : (maximum count = 1FFFh+rollover) 8192 – 230=(7962)10
In Hex decimal=1F1Ah
VASAVI COLLEGE OF ENGINEERING
Department of Information Technology
Course: BE Semester: VI Section: B

Roll no: 1602-18-737-080 Name: Mahalaxmi Bejugam Date of Submission: 8.04.2021

Name of the course: ES&IOT Lab

Output:

Result: Program to generate pulse, create delay with timer0 (T0) at P1.2 operate in
mode0 with frequency 2 KHz was executed successfully

Experiment 2: Timer in mode 1


Aim: Write a program to generate pulse, create delay with timer0 (T0) at P0.2
operate in mode1 with frequency 2 KHz.

Program:
mov tmod ,#01h;
l1: mov tl0,#1Ah;
mov th0,#0FFh;
cpl p0.2;
setb tr0;
VASAVI COLLEGE OF ENGINEERING
Department of Information Technology
Course: BE Semester: VI Section: B

Roll no: 1602-18-737-080 Name: Mahalaxmi Bejugam Date of Submission: 8.04.2021

Name of the course: ES&IOT Lab

target:jnb tf0,target;
clr tr0;
clr tf0;
sjmp l1 end
Calculations:
time period=1/2KHz =0.5millisecond.
For the half of the clock pulse time = 0.5/2=0.25 ms
Count= 0.25 milliseconds/1.085micro seconds = 230
In mode 1 : (maximum count = FFFFh + rollover) 65536 – 230=(65306)10
In Hex decimal=FF1Ah
Output:

Result: Program to generate pulse, create delay with timer0 (T0) at P0.2 operate in
mode1 with frequency 2 KHz was executed successfully
VASAVI COLLEGE OF ENGINEERING
Department of Information Technology
Course: BE Semester: VI Section: B

Roll no: 1602-18-737-080 Name: Mahalaxmi Bejugam Date of Submission: 8.04.2021

Name of the course: ES&IOT Lab

Experiment 3: Timer in mode 2


Aim: Write a program to generate pulse, create delay with timer0 (T0) at P1.1
operate in mode2 with frequency 2 KHz.

Program:
mov tmod ,#02h;
mov th0,#1Ah;
l1: cpl p1.1;
setb tr0;
target:jnb tf0,target;
clr tr0;
clr tf0;
sjmp l1
end
Calculations:
time period=1/2KHz=0.5millisecond.
For the half of the clock pulse time = 0.5/2=0.25 ms
Count=0.25 milliseconds/1.085micro seconds = 230
In mode 2: (maximum count = FFh + rollover) 256 – 230=(26)10
In Hex decimal=1Ah
VASAVI COLLEGE OF ENGINEERING
Department of Information Technology
Course: BE Semester: VI Section: B

Roll no: 1602-18-737-080 Name: Mahalaxmi Bejugam Date of Submission: 8.04.2021

Name of the course: ES&IOT Lab

Output:

Result: Program to generate pulse, create delay with timer0 (T0) at P1.1 operate in
mode2 with frequency 2 KHz was executed successfully

Experiment 4: Timer in mode 0


Aim: To write a C program to generate pulse, create delay with timer0 (T0) at P1.1
operate in mode0 with frequency 3 KHz.

Program:
#include <reg51.h>
void delay(void);
sbit a=P1^1;
void main(void){
while(1)
{
VASAVI COLLEGE OF ENGINEERING
Department of Information Technology
Course: BE Semester: VI Section: B

Roll no: 1602-18-737-080 Name: Mahalaxmi Bejugam Date of Submission: 8.04.2021

Name of the course: ES&IOT Lab

a=~a;
delay();
}
}
void delay(void){
TMOD=0x00;
TL0=0xF8;
TH0=0x20;
TR0=1;
while(TF0==0);
TR0=0;
TF0=0;
}

Calculations:
time period=1/3KHz =0.33millisecond.
For the half of the clock pulse time = 0.33/2=0.165 ms
Count= 0.165 milliseconds/1.085micro seconds = 152
In mode 0 : (maximum count = 1FFFh ) 8591 + 1(rollover) – 152=(8440)10
In Hex decimal=20F8H
VASAVI COLLEGE OF ENGINEERING
Department of Information Technology
Course: BE Semester: VI Section: B

Roll no: 1602-18-737-080 Name: Mahalaxmi Bejugam Date of Submission: 8.04.2021

Name of the course: ES&IOT Lab

Output:

Result: C program to generate pulse, create delay with timer0 (T0) at P1.1 operate in
mode0 with frequency 3 KHz was executed successfully..

Experiment 5: Timer in mode 1


Aim: Write a C program to generate pulse, create delay with timer0 (T0) at P1.2
operate in mode 1 with frequency 3 KHz.

Program:
#include <reg51.h>
void delay(void);
sbit a=P1^2;
VASAVI COLLEGE OF ENGINEERING
Department of Information Technology
Course: BE Semester: VI Section: B

Roll no: 1602-18-737-080 Name: Mahalaxmi Bejugam Date of Submission: 8.04.2021

Name of the course: ES&IOT Lab

void main(void){
while(1)
{
a=~a;
delay();
}
}
void delay(void){
TMOD=0x10;
TL0=0x68;
TH0=0xFF;
TR0=1;
while(TF0==0);
TR0=0;
TF0=0;
}

Calculations:
time period=1/3KHz =0.33millisecond.
For the half of the clock pulse time = 0.33/2=0.165 ms
Count= 0.165 milliseconds/1.085micro seconds = 152
In mode 1 : (maximum count = FFFFh ) 65535 + 1(rollover) – 152=(65384)10
In Hex decimal=FF68H
VASAVI COLLEGE OF ENGINEERING
Department of Information Technology
Course: BE Semester: VI Section: B

Roll no: 1602-18-737-080 Name: Mahalaxmi Bejugam Date of Submission: 8.04.2021

Name of the course: ES&IOT Lab

Output:

Result: C program to generate pulse, create delay with timer0 (T0) at P1.2 operate in
mode1 with frequency 3 KHz was executed successfully.

Experiment 6: Timer in mode 2


Aim: Write a C program to generate pulse, create delay with timer0 (T0) at P1.3
operate in mode 2 with frequency 3 KHz.

Program:
#include <reg51.h>
void delay(void);
sbit a=P1^3;
void main(void){
while(1)
{
VASAVI COLLEGE OF ENGINEERING
Department of Information Technology
Course: BE Semester: VI Section: B

Roll no: 1602-18-737-080 Name: Mahalaxmi Bejugam Date of Submission: 8.04.2021

Name of the course: ES&IOT Lab

a=~a;
delay();
}
}
void delay(void){
TMOD=0x02;
TH0= 0x68;
TR0=1;
while(TF0==0);
TR0=0;
TF0=0;
}
Calculations:
time period=1/3KHz =0.33millisecond.
For the half of the clock pulse time = 0.33/2=0.165 ms
Count=0.165 milliseconds/1.085micro seconds = 152
In mode 2 : (maximum count = FFH ) 255 + 1(rollover) – 152=(104)10
In Hex decimal=68H
VASAVI COLLEGE OF ENGINEERING
Department of Information Technology
Course: BE Semester: VI Section: B

Roll no: 1602-18-737-080 Name: Mahalaxmi Bejugam Date of Submission: 8.04.2021

Name of the course: ES&IOT Lab

Output:

Result: C program to generate pulse, create delay with timer0 (T0) at P1.3 operate in
mode2 with frequency 3 KHz was executed successfully.

Experiment 7
Aim: Write a C program to toggle all bits of port P1 continuously with some delay in
between. Use timer 0, 16-bit mode to generate the delay.

Program:
#include<reg51.h>

void T0Delay(void);

void main(void)

while(1)
VASAVI COLLEGE OF ENGINEERING
Department of Information Technology
Course: BE Semester: VI Section: B

Roll no: 1602-18-737-080 Name: Mahalaxmi Bejugam Date of Submission: 8.04.2021

Name of the course: ES&IOT Lab

P1=0x55;

T0Delay();

P1=0xAA;

T0Delay();

void T0Delay()

TMOD=0x01;

TL0=0x00;

TH0=0x35;

TR0=1;

while(TF0==0);

TR0=0;

TF0=0;

Calculations:
Maximum Count= FFFFH
Given TL0,TH0= 3500H
Count= FFFFH-3500H=CAFFH=(51967)10 + 1(roll over)= 51968
Delay= 51968*1.085 micro seconds=56.384milli seconds.
VASAVI COLLEGE OF ENGINEERING
Department of Information Technology
Course: BE Semester: VI Section: B

Roll no: 1602-18-737-080 Name: Mahalaxmi Bejugam Date of Submission: 8.04.2021

Name of the course: ES&IOT Lab

Output:

Result : C program to toggle all bits of port P1 continuously with some delay in
between by Use timer 0, 16-bit mode to generate the delay was executed
successfully
VASAVI COLLEGE OF ENGINEERING
Department of Information Technology
Course: BE Semester: VI Section: B
Roll no: 1602-18-737-080 Name: B. Mahalaxmi Date of Submission: 14.04.2021
Name of the course: ES&IOT Lab

Lab-4
Experiment -1:
Aim:
To write a assembly language program for the 8051 to transfer “YES” serially at 9600 baud,
8-bit data, 1 stop bit.
Program:
MOV TMOD,#20H
MOV TH1,#0fdh
MOV SCON,#40H
SETB TR1
MOV A,#'Y'
ACALL TRANS
MOV A,#'E'
ACALL TRANS
MOV A,#'S'
ACALL TRANS
CLR TR1
TRANS: MOV SBUF,A
HERE: JNB TI,HERE
CLR TI
RET
END
VASAVI COLLEGE OF ENGINEERING
Department of Information Technology
Course: BE Semester: VI Section: B
Roll no: 1602-18-737-080 Name: B. Mahalaxmi Date of Submission: 14.04.2021
Name of the course: ES&IOT Lab

OUTPUT:

RESULT:
Assembly language program for the 8051 to transfer “YES” serially at 9600 baud, 8-bit data,
1 stop bit is executed successfully.

Experiment 2:
Aim:
To write a assembly language program for the 8051 to transfer “YES” serially at 9600 baud,
8-bit data, 1 stop bit, do this continuously.
PROGRAM:
MOV TMOD,#20H
MOV SCON,#50H
SETB TR1
VASAVI COLLEGE OF ENGINEERING
Department of Information Technology
Course: BE Semester: VI Section: B
Roll no: 1602-18-737-080 Name: B. Mahalaxmi Date of Submission: 14.04.2021
Name of the course: ES&IOT Lab

AGAIN:MOV A,#'Y'
ACALL TRANS
MOV A,#'E'
ACALL TRANS
MOV A,#'S'
ACALL TRANS
SJMP AGAIN
TRANS: MOV SBUF,A
HERE: JNB TI,HERE
CLR TI
RET end
OUTPUT:
VASAVI COLLEGE OF ENGINEERING
Department of Information Technology
Course: BE Semester: VI Section: B
Roll no: 1602-18-737-080 Name: B. Mahalaxmi Date of Submission: 14.04.2021
Name of the course: ES&IOT Lab

RESULT:
Assembly language program for the 8051 to transfer “YES” serially at 9600 baud, 8-bit data,
1 stop bit, do this continuously is executed successfully.

Experiment-3:
Aim:
To write a embedded c program for the 8051 to transfer “YES” serially at 9600 baud, 8-bit
data, 1 stop bit.
Program:
#include
<reg51.h>
void
SerTx(unsig
ned char);
void
main(void){
TMOD=0x20;
TH1=0xFD;
SCON=0x50;
TR1=1;

SerTx('Y');
SerTx('E');
SerTx('S');

}
VASAVI COLLEGE OF ENGINEERING
Department of Information Technology
Course: BE Semester: VI Section: B
Roll no: 1602-18-737-080 Name: B. Mahalaxmi Date of Submission: 14.04.2021
Name of the course: ES&IOT Lab

Void
SerTx(unsigne
d char x){
SBUF=x;
while (TI==0);
TI=0;
}

OUTPUT:
VASAVI COLLEGE OF ENGINEERING
Department of Information Technology
Course: BE Semester: VI Section: B
Roll no: 1602-18-737-080 Name: B. Mahalaxmi Date of Submission: 14.04.2021
Name of the course: ES&IOT Lab

RESULT:
Embedded c program for the 8051 to transfer “YES” serially at 9600 baud, 8-bit data, 1 stop
bit is executed successfully.

Experiment4:
Aim:
To write a embedded c program for the 8051 to transfer “YES” serially at 9600 baud, 8-bit
data, 1 stop bit, do this continuously.
Program:
#include
<reg51.h>
void
SerTx(unsig
ned char);
void
main(void){
TMOD=0x20;
TH1=0xFD;
SCON
=0x5
0;
TR1=
1;
while
(1)
VASAVI COLLEGE OF ENGINEERING
Department of Information Technology
Course: BE Semester: VI Section: B
Roll no: 1602-18-737-080 Name: B. Mahalaxmi Date of Submission: 14.04.2021
Name of the course: ES&IOT Lab

{SerTx
('Y');
SerTx('E');
SerTx('S');
}
}
void SerTx(unsigned
char x){ SBUF=x;
while (TI==0);
TI=0;
}
VASAVI COLLEGE OF ENGINEERING
Department of Information Technology
Course: BE Semester: VI Section: B
Roll no: 1602-18-737-080 Name: B. Mahalaxmi Date of Submission: 14.04.2021
Name of the course: ES&IOT Lab

OUTPUT:

RESULT:
Embedded c program for the 8051 to transfer “YES” serially at 9600 baud, 8-bit data, 1 stop
bit, do this continuously is executed successfully.
VASAVI COLLEGE OF ENGINEERING
Department of Information Technology
Course: BE Semester: VI Section: B

Roll no: 1602-18-737-080 Name: B. Mahalaxmi Date of Submission: 17.04.2021

Name of the course: ES&IOT Lab

LAB-5
Experiment 1:
Aim: To write a assembly language program that continuously sets 8 bit data from P0 and sends it
to P1 , which simultaneously generates square wave of 200 micro sec period on p2.1 using T0
register to create delay and assuming that XTAL frequency 11.0592 Mhz.

Program:
ORG 0000H

LJMP L1

ORG 000BH

CPL P2.1

RETI

ORG 0030H

L1: MOV TMOD,#02H

MOV P0,#0FFH

MOV TH0,#-92

MOV IE,#82H

;Timer 0

SETB TR0

L2: MOV A,P0

MOV P1,A

SJMP L2

END
VASAVI COLLEGE OF ENGINEERING
Department of Information Technology
Course: BE Semester: VI Section: B

Roll no: 1602-18-737-080 Name: B. Mahalaxmi Date of Submission: 17.04.2021

Name of the course: ES&IOT Lab

Output:

Result: Assembly language program that continuously sets 8 bit data from P0 and sends it to P1 ,
which simultaneously generates square wave of 200 micro sec period on p2.1 using T0 register to
create delay is executed successfully.
VASAVI COLLEGE OF ENGINEERING
Department of Information Technology
Course: BE Semester: VI Section: B

Roll no: 1602-18-737-080 Name: B. Mahalaxmi Date of Submission: 17.04.2021

Name of the course: ES&IOT Lab

Experiment 2:
Aim: To write a assembly language program in which the 8051 reads data from P1 and writes it to
P2 continuously , while giving copy of it to the serial port , When ever it receives a character from
serial gives a copy of it to P0 ( Assume XTAL frequency is 11.0592 MHz , baud rate is 9600 ).

Program:
MOV P1 , # 0FFH

Mov TMOD ,# 20H

Mov TH1, # 0FDH

Mov SCON ,# 50H

MOV IE ,# 90H

SETB TR1

L1: Mov A, P1

MOV SBUF ,A

Mov p2 ,A

SJMP L1

ORG 23H

L2: JB TI ,L3

MOV A, SBUF

MOV P0,A

CLR RI

RETI

L3: CLR TI

RETI

END
VASAVI COLLEGE OF ENGINEERING
Department of Information Technology
Course: BE Semester: VI Section: B

Roll no: 1602-18-737-080 Name: B. Mahalaxmi Date of Submission: 17.04.2021

Name of the course: ES&IOT Lab

Output:
VASAVI COLLEGE OF ENGINEERING
Department of Information Technology
Course: BE Semester: VI Section: B

Roll no: 1602-18-737-080 Name: B. Mahalaxmi Date of Submission: 17.04.2021

Name of the course: ES&IOT Lab

Result: Assembly language program in which the 8051 reads data from P1 and writes it to P2
continuously , while giving copy of it to the serial port , When ever it receives a character from serial
gives a copy of it to P0 is executed successfully.
VASAVI COLLEGE OF ENGINEERING
AUTONOMOUS
(Affiliated to Osmania University)
Hyderabad- 500 031
DEPARTMENT OF : INFORMATION TECHNOLOGY
NAME OF THE LABORATORY : Embedded Systems and IoT LAB _
Name B. Mahalaxmi ______ Roll No. 1602-18-737-080

WEEK-6

Experiment 1:

Aim: To write a assembly language program for rotating stepper motor 180 o anticlockwise
continuously.
Flowcahrt:
VASAVI COLLEGE OF ENGINEERING
AUTONOMOUS
(Affiliated to Osmania University)
Hyderabad- 500 031
DEPARTMENT OF : INFORMATION TECHNOLOGY
NAME OF THE LABORATORY : Embedded Systems and IoT LAB _
Name B. Mahalaxmi ______ Roll No. 1602-18-737-080

PROGRAM:
L1:MOV R4,#100D

MOV A,#11H

BACK: MOV P2,A

RR A

ACALL DELAY

DJNZ R4,BACK

DELAY:MOV R2,#200

H1:MOV R3,#255

H2:DJNZ R3,H2

DJNZ R2,H1

RET

SJMP L1

END

Program:
VASAVI COLLEGE OF ENGINEERING
AUTONOMOUS
(Affiliated to Osmania University)
Hyderabad- 500 031
DEPARTMENT OF : INFORMATION TECHNOLOGY
NAME OF THE LABORATORY : Embedded Systems and IoT LAB _
Name B. Mahalaxmi ______ Roll No. 1602-18-737-080

Before Execution design look like:

After Execution design look like:

RESULT:

Assembly language program for rotating stepper motor 180 o anticlockwise continuously is
executedsuccessfully.
VASAVI COLLEGE OF ENGINEERING
AUTONOMOUS
(Affiliated to Osmania University)
Hyderabad- 500 031
DEPARTMENT OF : INFORMATION TECHNOLOGY
NAME OF THE LABORATORY : Embedded Systems and IoT LAB _
Name B. Mahalaxmi ______ Roll No. 1602-18-737-080

Experiment 2:

Aim: To write a assembly language program for rotating stepper motor 180 o clockwise
continuously.

Program:

L1:MOV R4,#100D
MOV A,#11H
BACK: MOV P2,A
VASAVI COLLEGE OF ENGINEERING
AUTONOMOUS
(Affiliated to Osmania University)
Hyderabad- 500 031
DEPARTMENT OF : INFORMATION TECHNOLOGY
NAME OF THE LABORATORY : Embedded Systems and IoT LAB _
Name B. Mahalaxmi ______ Roll No. 1602-18-737-080

RL A
ACALL DELAY
DJNZ R4,BACK
DELAY:MOV R2,#200
H1:MOV R3,#255
H2:DJNZ R3,H2
DJNZ R2,H1
RET
SJMP L1
END

OUTPUT:

Before execution Design:


VASAVI COLLEGE OF ENGINEERING
AUTONOMOUS
(Affiliated to Osmania University)
Hyderabad- 500 031
DEPARTMENT OF : INFORMATION TECHNOLOGY
NAME OF THE LABORATORY : Embedded Systems and IoT LAB _
Name B. Mahalaxmi ______ Roll No. 1602-18-737-080

After execution Design:

Result Assembly language program for rotating stepper motor 180 o clockwise continuously is
executedsuccessfully .
VASAVI COLLEGE OF ENGINEERING
AUTONOMOUS
(Affiliated to Osmania University)
Hyderabad- 500 031
DEPARTMENT OF : INFORMATION TECHNOLOGY
NAME OF THE LABORATORY : Embedded Systems and IoT LAB _
Name B. Mahalaxmi ______ Roll No. 1602-18-737-080

Exp 3:
Aim: To write a assembly language program for rotating stepper motor 360 o clockwise
and 360 o anti clock wisecontinuously

Program:
L1:MOV R2,#200d
VASAVI COLLEGE OF ENGINEERING
AUTONOMOUS
(Affiliated to Osmania University)
Hyderabad- 500 031
DEPARTMENT OF : INFORMATION TECHNOLOGY
NAME OF THE LABORATORY : Embedded Systems and IoT LAB _
Name B. Mahalaxmi ______ Roll No. 1602-18-737-080

MOV A,#11H

H2:MOV P2,A

MOV R3,#11111111b

H1:DJNZ R3,H1

RR A

DJNZ R2,H2

MOV R2,#200D

H4:MOV P2,A

MOV R3,#11111111b

H5:DJNZ R3,H5

RL A

DJNZ R2,H4

SJMP L1

END

Output:
VASAVI COLLEGE OF ENGINEERING
AUTONOMOUS
(Affiliated to Osmania University)
Hyderabad- 500 031
DEPARTMENT OF : INFORMATION TECHNOLOGY
NAME OF THE LABORATORY : Embedded Systems and IoT LAB _
Name B. Mahalaxmi ______ Roll No. 1602-18-737-080

Before executing design looks like:

After executing design looks like:

Result:
Assembly language program for rotating stepper motor 360 o clockwise and 360 o anti
clock wisecontinuously is executed successfully.
VASAVI COLLEGE OF ENGINEERING
AUTONOMOUS
(Affiliated to Osmania University)
Hyderabad- 500 031
DEPARTMENT OF : INFORMATION TECHNOLOGY
NAME OF THE LABORATORY : Embedded Systems and IoT LAB _
Name B. Mahalaxmi______ Roll No. 1602-18-737-080

WEEK-7

Experiment 1:

Aim: To write an assembly language program that displays “ESLAB VCE IT DEPT” on LCD
continuously.

Flowcahrt:
VASAVI COLLEGE OF ENGINEERING
AUTONOMOUS
(Affiliated to Osmania University)
Hyderabad- 500 031
DEPARTMENT OF : INFORMATION TECHNOLOGY
NAME OF THE LABORATORY : Embedded Systems and IoT LAB _
Name B. Mahalaxmi______ Roll No. 1602-18-737-080
VASAVI COLLEGE OF ENGINEERING
AUTONOMOUS
(Affiliated to Osmania University)
Hyderabad- 500 031
DEPARTMENT OF : INFORMATION TECHNOLOGY
NAME OF THE LABORATORY : Embedded Systems and IoT LAB _
Name B. Mahalaxmi______ Roll No. 1602-18-737-080

PROGRAM:

#include<reg51.h>

void lcdcmd(unsigned char);

void msdelay(unsigned int);

void lcddata(unsigned char);

sfr ldata=0xA0;

sbit rs=P3^7;

sbit rw=P3^6;
VASAVI COLLEGE OF ENGINEERING
AUTONOMOUS
(Affiliated to Osmania University)
Hyderabad- 500 031
DEPARTMENT OF : INFORMATION TECHNOLOGY
NAME OF THE LABORATORY : Embedded Systems and IoT LAB _
Name B. Mahalaxmi______ Roll No. 1602-18-737-080

sbit en=P3^5;

void main()

while(1)

lcdcmd(0x38); // function set 8-bit mode 2 line and 5X7 dot matrix

msdelay(25); // delay function

lcdcmd(0x0e); // display on and cursor on

msdelay(500);

lcdcmd(0x01); // clear display screen

msdelay(500);

lcdcmd(0x06); // entry mode( shift cursor to right)

msdelay(500);

lcdcmd(0x85); // force cursor to 4th position of the line 1

msdelay(500);

lcddata('E'); // diplay character "E" ON THE LCD

msdelay(500);

lcddata('S'); // diplay character "S" ON THE LCD

msdelay(500);

lcddata('L'); // diplay character "L" ON THE LCD

msdelay(500);

lcddata('A'); // diplay character "A" ON THE LCD

msdelay(500);

lcddata('B'); // diplay character "B" ON THE LCD

msdelay(500);

lcdcmd(0xC2);

msdelay(500);
VASAVI COLLEGE OF ENGINEERING
AUTONOMOUS
(Affiliated to Osmania University)
Hyderabad- 500 031
DEPARTMENT OF : INFORMATION TECHNOLOGY
NAME OF THE LABORATORY : Embedded Systems and IoT LAB _
Name B. Mahalaxmi______ Roll No. 1602-18-737-080

lcddata('V');

msdelay(500);

lcddata('C');

msdelay(500);

lcddata('E');

msdelay(500);

lcddata(' ');

msdelay(500);

lcddata('I');

msdelay(500);

lcddata('T');

msdelay(500);

lcddata(' ');

msdelay(500);

lcddata('D');

msdelay(500);

lcddata('E');

msdelay(500);

lcddata('P');

msdelay(500);

lcddata('T');

msdelay(500);

void lcdcmd(unsigned char value)

{
VASAVI COLLEGE OF ENGINEERING
AUTONOMOUS
(Affiliated to Osmania University)
Hyderabad- 500 031
DEPARTMENT OF : INFORMATION TECHNOLOGY
NAME OF THE LABORATORY : Embedded Systems and IoT LAB _
Name B. Mahalaxmi______ Roll No. 1602-18-737-080

ldata=value;

rs=0;

rw=0;

en=1;

msdelay(1);

en=0;

return;

void lcddata(unsigned char value)

ldata=value;

rs=1;

rw=0;

en=1;

msdelay(1);

en=0;

return;

void msdelay(unsigned int itime)

unsigned int i,j;

for(i=0;i<itime;i++);

for(j=0;j<1275;j++);

}
VASAVI COLLEGE OF ENGINEERING
AUTONOMOUS
(Affiliated to Osmania University)
Hyderabad- 500 031
DEPARTMENT OF : INFORMATION TECHNOLOGY
NAME OF THE LABORATORY : Embedded Systems and IoT LAB _
Name B. Mahalaxmi______ Roll No. 1602-18-737-080

Before Execution design look like:

After Execution design look like:

RESULT:
Assembly language program that displays “ESLAB VCE IT DEPT” on LCD continuously is successfully
executed.
VASAVI COLLEGE OF ENGINEERING
AUTONOMOUS
(Affiliated to Osmania University)
Hyderabad- 500 031
DEPARTMENT OF : INFORMATION TECHNOLOGY
NAME OF THE LABORATORY : Embedded Systems and IoT LAB _
Name B. Mahalaxmi______ Roll No. 1602-18-737-080

WEEK-8
Experiment 1:
Aim: To write a assembly language program that displays a Sawtooth wave
using digital data entered to DAC .

PROGRAM:
Back1: Mov A,#00H
Mov R0,# 0FFH
Back: Mov P2,A
Inc A
Djnz R0,Back
Sjmp Back1
End
VASAVI COLLEGE OF ENGINEERING
AUTONOMOUS
(Affiliated to Osmania University)
Hyderabad- 500 031
DEPARTMENT OF : INFORMATION TECHNOLOGY
NAME OF THE LABORATORY : Embedded Systems and IoT LAB _
Name B. Mahalaxmi______ Roll No. 1602-18-737-080

KEIL μ VISION OUTPUT:

Output:
VASAVI COLLEGE OF ENGINEERING
AUTONOMOUS
(Affiliated to Osmania University)
Hyderabad- 500 031
DEPARTMENT OF : INFORMATION TECHNOLOGY
NAME OF THE LABORATORY : Embedded Systems and IoT LAB _
Name B. Mahalaxmi______ Roll No. 1602-18-737-080

RESULT: Assembly language program that displays a sawtooth wave using digital data entered to
DAC is executed successfully.

Experiment 2:

AimTo write a assembly language program that displays a square wave using digital data
entered to DAC .

Program:

Mov A,#00H
L2: Mov P2,A
Mov R0,#0FFH
L1: Djnz R0,L1
Cpl A
Sjmp L2

OUTPUT:
VASAVI COLLEGE OF ENGINEERING
AUTONOMOUS
(Affiliated to Osmania University)
Hyderabad- 500 031
DEPARTMENT OF : INFORMATION TECHNOLOGY
NAME OF THE LABORATORY : Embedded Systems and IoT LAB _
Name B. Mahalaxmi______ Roll No. 1602-18-737-080

Before execution Design:

After execution Design:


VASAVI COLLEGE OF ENGINEERING
AUTONOMOUS
(Affiliated to Osmania University)
Hyderabad- 500 031
DEPARTMENT OF : INFORMATION TECHNOLOGY
NAME OF THE LABORATORY : Embedded Systems and IoT LAB _
Name B. Mahalaxmi______ Roll No. 1602-18-737-080

Result Assembly language program that displays a square wave using digital data entered
to DAC is executed successfully .

Exp 3:
Aim: To write assembly language program that displays a triangular wave using digital
data entered to DAC

Program:
Back1: Mov A,00H

Mov R0, #0FFH

Back :Mov P2,A

Inc A

Djnz R0 ,Back

Mov R0,# 0FFH


VASAVI COLLEGE OF ENGINEERING
AUTONOMOUS
(Affiliated to Osmania University)
Hyderabad- 500 031
DEPARTMENT OF : INFORMATION TECHNOLOGY
NAME OF THE LABORATORY : Embedded Systems and IoT LAB _
Name B. Mahalaxmi______ Roll No. 1602-18-737-080

Back2 : Mov P0,A

Dec A

Djnz R0 ,Back2

Sjmp Back1

end

Output:

Design:
VASAVI COLLEGE OF ENGINEERING
AUTONOMOUS
(Affiliated to Osmania University)
Hyderabad- 500 031
DEPARTMENT OF : INFORMATION TECHNOLOGY
NAME OF THE LABORATORY : Embedded Systems and IoT LAB _
Name B. Mahalaxmi______ Roll No. 1602-18-737-080

Result:
Assembly language program that displays a triangular wave using digital data entered to DAC is
executed successfully.
VASAVI COLLEGE OF ENGINEERING
AUTONOMOUS
(Affiliated to Osmania University)
Hyderabad- 500 031
DEPARTMENT OF : INFORMATION TECHNOLOGY
NAME OF THE LABORATORY : Embedded Systems and IoT LAB _
Name B. Mahalaxmi______ Roll No. 1602-18-737-080

Exp 4:

Aim: To write a embedded C program that displays a sawtooth wave using digital data entered to
DAC

Program:

# include <reg 51.h>

void main(void)

unsigned int x;

While(1)

for( x=0; x< 255; x++)

P0= x;

x=0;

P0=x;

}
VASAVI COLLEGE OF ENGINEERING
AUTONOMOUS
(Affiliated to Osmania University)
Hyderabad- 500 031
DEPARTMENT OF : INFORMATION TECHNOLOGY
NAME OF THE LABORATORY : Embedded Systems and IoT LAB _
Name B. Mahalaxmi______ Roll No. 1602-18-737-080

Output:

Design:
VASAVI COLLEGE OF ENGINEERING
AUTONOMOUS
(Affiliated to Osmania University)
Hyderabad- 500 031
DEPARTMENT OF : INFORMATION TECHNOLOGY
NAME OF THE LABORATORY : Embedded Systems and IoT LAB _
Name B. Mahalaxmi______ Roll No. 1602-18-737-080

Result:
Embedded C program that displays a sawtooth wave using digital data entered to DAC is executed
successfully.

Exp 5:

Aim:

To write a embedded C program that displays a square wave using digital data entered to DAC .

Program:
#include<reg51.h>

void delay()

int i=0;

for(i=0;i<192;i++);

void main()

while(1)

P2=0XFF;

delay();

P2=0X00;

delay();

} }
VASAVI COLLEGE OF ENGINEERING
AUTONOMOUS
(Affiliated to Osmania University)
Hyderabad- 500 031
DEPARTMENT OF : INFORMATION TECHNOLOGY
NAME OF THE LABORATORY : Embedded Systems and IoT LAB _
Name B. Mahalaxmi______ Roll No. 1602-18-737-080

Output:

Design :
VASAVI COLLEGE OF ENGINEERING
AUTONOMOUS
(Affiliated to Osmania University)
Hyderabad- 500 031
DEPARTMENT OF : INFORMATION TECHNOLOGY
NAME OF THE LABORATORY : Embedded Systems and IoT LAB _
Name B. Mahalaxmi______ Roll No. 1602-18-737-080

Result:
Embedded C program that displays a square wave using digital data entered to DAC is executed
successfully.

Exp 6 :
Aim:
To write a embedded C program that displays a triangular wave using digital data entered to DAC .

Program:
# include<reg51.h>

void main(void)

unsigned int x;

while(1)

for( x=0; x< 255; x++)

P2= x;

for ( x=255 ;x>0; x--)

P2=x;

}
VASAVI COLLEGE OF ENGINEERING
AUTONOMOUS
(Affiliated to Osmania University)
Hyderabad- 500 031
DEPARTMENT OF : INFORMATION TECHNOLOGY
NAME OF THE LABORATORY : Embedded Systems and IoT LAB _
Name B. Mahalaxmi______ Roll No. 1602-18-737-080

Output:

Design:

Result:
Embedded C program that displays a triangular wave using digital data entered to DAC is executed
successfully.
VASAVI COLLEGE OF ENGINEERING
AUTONOMOUS
(Affiliated to Osmania University)
Hyderabad- 500 031
DEPARTMENT OF : INFORMATION TECHNOLOGY
NAME OF THE LABORATORY : Embedded Systems and IoT LAB _
Name B. Mahalaxmi______ Roll No. 1602-18-737-080

WEEK-9
Experiment 1:
Aim : To write a assembly language program that displays digits 0-9 in 7 segmented
display (interfacing 7 segmented display with 8051)

PROGRAM:
ORG 4000H
DB 3FH, 06H, 5BH, 4FH, 66H, 6DH, 7DH, 07H, 7FH, 6FH
ORG 0000H
main: MOV DPTR, #4000H
repeat: CLR A
MOVC A, @A+DPTR
MOV P2, A
ACALL delay
INC DPTR
CJNE A, 0, repeat
SJMP main
delay: MOV R0, #08H
LP2: MOV R1, #0FFH
LP1:MOV R2, #0FFH
LP3:DJNZ R2, LP3
DJNZ R1, LP1
DJNZ R0, LP2
RET
END
VASAVI COLLEGE OF ENGINEERING
AUTONOMOUS
(Affiliated to Osmania University)
Hyderabad- 500 031
DEPARTMENT OF : INFORMATION TECHNOLOGY
NAME OF THE LABORATORY : Embedded Systems and IoT LAB _
Name B. Mahalaxmi______ Roll No. 1602-18-737-080

KEIL μ VISION OUTPUT:

Design Output:
VASAVI COLLEGE OF ENGINEERING
AUTONOMOUS
(Affiliated to Osmania University)
Hyderabad- 500 031
DEPARTMENT OF : INFORMATION TECHNOLOGY
NAME OF THE LABORATORY : Embedded Systems and IoT LAB _
Name B. Mahalaxmi______ Roll No. 1602-18-737-080

RESULT: Assembly language program that displays digits 0-9 in 7 segmented display is
executed successfully.
VASAVI COLLEGE OF ENGINEERING
Department of Information Technology
Course: BE Semester: VI Section: A

Roll No: 1602-18-737-080 Name: B. Mahalaxmi Name of the Course: ES-IOT Lab

1.Aim:
Write a program in assembly language to interface ADC and display message on LCD.
Algorithm:
Step 1: Start
Step 2: Equate P0.0 to ADDA, P0.1 to ADDB, P0.2 to ADDC, P0.3 to ale, P0.4 to sc, P0.5 to
eoc, P0.6 to oe.
Step 3: Input a number and convert to ascii format using user defined by convert().
Step 4: Save code and add to Target->Source Group and click on build target.
Step 5: Then click on Flash->Output, give filename and convert to hex file by clicking on
“OK”.
Step 6: Now, do Translate and press Build target. (hex file will generate in objects file).
Step 7: Now, go to proteus software and add required components (89c51, lcd,adc) and give
connections.
Step 8: Now, load the hex file into 8051.
Step 9: Click on Run button.
Step 10: Stop.

Program:
#include<MYLIB.h>//1602-18-737-080
#define input_port P1 //ADC
//sfr input_port=0x90;
sbit ADDA=P0^0; //Address pins for selecting input channels.
sbit ADDB=P0^1;
sbit ADDC=P0^2;
sbit ale=P0^3;
sbit sc=P0^4;
sbit eoc=P0^5;
VASAVI COLLEGE OF ENGINEERING
Department of Information Technology
Course: BE Semester: VI Section: A

Roll No: 1602-18-737-080 Name: B. Mahalaxmi Name of the Course: ES-IOT Lab

sbit oe=P0^6;

unsigned char number;

void convert(unsigned char value)


{
unsigned char x,d1,d2,d3;
x=value/10;
d1=value%10;
d2=x%10;
d3=x/10;
lcddata(d3+48);
msdelay(1);
lcddata(d2+48);
msdelay(1);
lcddata(d1+48);
msdelay(10);
}

void main()
{
number=0;
eoc=1; // eoc as input pin
ale=0; // eoc as output pin
oe=0; // eoc as output pin
sc=0; // eoc as output pin
VASAVI COLLEGE OF ENGINEERING
Department of Information Technology
Course: BE Semester: VI Section: A

Roll No: 1602-18-737-080 Name: B. Mahalaxmi Name of the Course: ES-IOT Lab

ADDC=0; // Selecting input channel IN0 using address lines


ADDB=0;
ADDA=0;

lcd_init8bit();
lcdcmd(0x83);
lcdprint(" ADC 0808 ");
lcdcmd(0xc1);
lcdprint(" Interfacing ");
msdelay(500);
lcdcmd(1);

while(1)
{
ADDC=0; // Selecting input channel IN0 using address lines
ADDB=0;
ADDA=0;
ale=1;
sc=1;
msdelay(1);
ale=0;
sc=0;

while(eoc==0);
oe=1;
number=input_port;
VASAVI COLLEGE OF ENGINEERING
Department of Information Technology
Course: BE Semester: VI Section: A

Roll No: 1602-18-737-080 Name: B. Mahalaxmi Name of the Course: ES-IOT Lab

msdelay(1);
oe=0;
lcdcmd(0x80);
lcdprint("var res = ");
convert(number);

}
}
Output:
VASAVI COLLEGE OF ENGINEERING
Department of Information Technology
Course: BE Semester: VI Section: A

Roll No: 1602-18-737-080 Name: B. Mahalaxmi Name of the Course: ES-IOT Lab
VASAVI COLLEGE OF ENGINEERING
Department of Information Technology
Course: BE Semester: VI Section: A

Roll No: 1602-18-737-080 Name: B. Mahalaxmi Name of the Course: ES-IOT Lab

Result:
Program in assembly language to interface ADC and display message on LCD is completed
successfully.
VASAVI COLLEGE OF ENGINEERING
AUTONOMOUS
(Affiliated to Osmania University)
Hyderabad- 500 031
DEPARTMENT OF : INFORMATION TECHNOLOGY
NAME OF THE LABORATORY : ES & IOT ________
Name B. Mahalaxmi________ Roll No. 1602-18-737-080 Page No. _1 .

LAB-12
EXPERIMENT-1:
Aim: To write a program to blink LED using Arduino board.
Algorithm:
Step1: Take Arduino board, LED, Resistor.
Step2: Connect one end of LED to ground and another to pin13 using resistor.
Step3: Start simulation.
Step4: Stop.
Program:
// C++ code
//
/*
This program blinks pin 13 of the Arduino (the built-in LED)
*/
void setup()
{
pinMode(13, OUTPUT);
}
void loop()
{
// turn the LED on (HIGH is the voltage level)
digitalWrite(13, HIGH);
delay(1000); // Wait for 1000 millisecond(s)
// turn the LED off by making the voltage LOW
digitalWrite(13, LOW);
delay(1000); // Wait for 1000 millisecond(s)
VASAVI COLLEGE OF ENGINEERING
AUTONOMOUS
(Affiliated to Osmania University)
Hyderabad- 500 031
DEPARTMENT OF : INFORMATION TECHNOLOGY
NAME OF THE LABORATORY : ES & IOT ________
Name B. Mahalaxmi________ Roll No. 1602-18-737-080 Page No. _2 .

Output:
Design:

Design Output:

Result: The Program to blink LED using Arduino Board is executed successfully.

EXPERIMENT-2:
Aim: To write a program to interface Ultrasonic distance sensor with Arduino board.
Algorithm:
Step1: Take Arduino board, LED, Resistor, Ultrasonic distance sensor.
Step2: Connect digital input pin7 to SIG pin of Ultrasonic sensor,5v pin of Arduino to 5V pin
of sensor and ground to ground.
Step3: Start simulation.
Step4: stop.
Program:
int inches = 0; int cm = 0;
long readUltrasonicDistance(int pin)
VASAVI COLLEGE OF ENGINEERING
AUTONOMOUS
(Affiliated to Osmania University)
Hyderabad- 500 031
DEPARTMENT OF : INFORMATION TECHNOLOGY
NAME OF THE LABORATORY : ES & IOT ________
Name B. Mahalaxmi________ Roll No. 1602-18-737-080 Page No. _3 .

{
pinMode(pin, OUTPUT); // Clear the trigger
digitalWrite(pin, LOW);
delayMicroseconds(2);
// Sets the pin on HIGH state for 10 micro seconds
digitalWrite(pin, HIGH);
delayMicroseconds(10);
digitalWrite(pin, LOW);
pinMode(pin, INPUT);
// Reads the pin, and returns the sound wave travel time in microseconds
return pulseIn(pin, HIGH);
}
void setup()
{
pinMode(7, INPUT);
Serial.begin(9600);
}
void loop()
{
// measure the ping time in cm
cm = 0.01723 * readUltrasonicDistance(7);
// convert to inches by dividing by 2.54 inches = (cm / 2.54);
Serial.print(inches);
Serial.print("in, ");
Serial.print(cm);
Serial.println("cm");
delay(100); // Wait for 100 millisecond(s)
VASAVI COLLEGE OF ENGINEERING
AUTONOMOUS
(Affiliated to Osmania University)
Hyderabad- 500 031
DEPARTMENT OF : INFORMATION TECHNOLOGY
NAME OF THE LABORATORY : ES & IOT ________
Name B. Mahalaxmi________ Roll No. 1602-18-737-080 Page No. _4 .

}
Design:

Output:

Result: The Program to interface Ultrasonic distance sensor with Arduino Uno board and
calculating distance is successfully executed.
VASAVI COLLEGE OF ENGINEERING
AUTONOMOUS
(Affiliated to Osmania University)
Hyderabad- 500 031
DEPARTMENT OF : INFORMATION TECHNOLOGY
NAME OF THE LABORATORY : ES & IOT ________
Name B. Mahalaxmi________ Roll No. 1602-18-737-080 Page No. _5 .

EXPERIMENT-3:
Aim: To write a program to toggle led with push button.
Algorithm:
Step1: Take Arduino board, LED, Resistor, push button.
Step2: Connect one end of LED to ground and another to pin13.Connect one end of push
button to pin 2 of Arduino. Another end to 5v using resistor. Another end to Ground.
Step3: Start simulation.
Step4: stop.
Program:
int buttonState = 0;
void setup()
{
pinMode(2, INPUT);
pinMode(13, OUTPUT);
}
void loop()
{
// read the state of the pushbutton value
buttonState = digitalRead(2);
// check if pushbutton is pressed. if it is, the
// buttonState is HIGH
if (buttonState == HIGH) {
// turn LED on digitalWrite(13, HIGH);
} else {
// turn LED off digitalWrite(13, LOW);
}
delay(10); // Delay a little bit to improve simulation performance
}
VASAVI COLLEGE OF ENGINEERING
AUTONOMOUS
(Affiliated to Osmania University)
Hyderabad- 500 031
DEPARTMENT OF : INFORMATION TECHNOLOGY
NAME OF THE LABORATORY : ES & IOT ________
Name B. Mahalaxmi________ Roll No. 1602-18-737-080 Page No. _6 .

Output:
Design:

Result: Controlling blinking of LED with push button is successfully executed.

EXPERIMENT-4:
Aim: To write a Program to interface gas sensor to Arduino Board.
Algorithm:
Step 1: Take Arduino board, breadboard, gas sensor, Resistor.
Step 2: Connect top ends of sensor to ground of breadboard. And down end to A0, another to
ground using resistor. So, it will read through Analog Read.
Step 3: When you bring dirt near to sensor it outputs big number and we you take away from
sensor it projects small values.
Step 4: Start simulation.
Step 5: stop.
Program:
// C++ code
VASAVI COLLEGE OF ENGINEERING
AUTONOMOUS
(Affiliated to Osmania University)
Hyderabad- 500 031
DEPARTMENT OF : INFORMATION TECHNOLOGY
NAME OF THE LABORATORY : ES & IOT ________
Name B. Mahalaxmi________ Roll No. 1602-18-737-080 Page No. _7 .

int gassensorval=0;
void setup()
{
pinMode(A0, INPUT);
Serial.begin(9600);
}
void loop()
{
gassensorval=analogRead(A0);
Serial.println(gassensorval);
delay(10);
}

Design:

Output:
VASAVI COLLEGE OF ENGINEERING
AUTONOMOUS
(Affiliated to Osmania University)
Hyderabad- 500 031
DEPARTMENT OF : INFORMATION TECHNOLOGY
NAME OF THE LABORATORY : ES & IOT ________
Name B. Mahalaxmi________ Roll No. 1602-18-737-080 Page No. _8 .

Result: The program to interface gas sensor with Arduino Uno board and calculating the
value is successfully executed

EXPERIMENT-5:
Aim: To write a Program to interface Micro Servo with Arduino Board.
Algorithm:
Step 1: Take Arduino board, Micro servo.
Step 2: Connect the boards with servo with wires as shown. Step 3: It displays rotate 180
degrees.
Step 4: Start simulation.
Step 5: stop.
Program:
// C++ code
//
/*
Sweep

by BARRAGAN <http://barraganstudio.com> This example code is in the public domain.


VASAVI COLLEGE OF ENGINEERING
AUTONOMOUS
(Affiliated to Osmania University)
Hyderabad- 500 031
DEPARTMENT OF : INFORMATION TECHNOLOGY
NAME OF THE LABORATORY : ES & IOT ________
Name B. Mahalaxmi________ Roll No. 1602-18-737-080 Page No. _9 .

modified 8 Nov 2013 by Scott Fitzgerald http://www.arduino.cc/en/Tutorial/Sweep


*/

#include <Servo.h>
int pos = 0;
Servo servo_9;

void setup()
{
servo_9.attach(9, 500, 2500);

void loop()
{
// sweep the servo from 0 to 180 degrees in steps of 1 degrees

for (pos = 0; pos <= 180; pos += 1) {


// tell servo to go to position in variable 'pos' servo_9.write(pos);
// wait 15 ms for servo to reach the position delay(15); // Wait for 15 millisecond(s)
}
for (pos = 180; pos >= 0; pos -= 1) {
// tell servo to go to position in variable 'pos' servo_9.write(pos);
// wait 15 ms for servo to reach the position delay(15); // Wait for 15 millisecond(s)
}
}
Design:
VASAVI COLLEGE OF ENGINEERING
AUTONOMOUS
(Affiliated to Osmania University)
Hyderabad- 500 031
DEPARTMENT OF : INFORMATION TECHNOLOGY
NAME OF THE LABORATORY : ES & IOT ________
Name B. Mahalaxmi________ Roll No. 1602-18-737-080 Page No. _10 .

Output:

Result: The program to interface Micro Servo with Arduino Board is successfully executed.
VASAVI COLLEGE OF ENGINEERING
AUTONOMOUS
(Affiliated to Osmania University)
Hyderabad- 500 031
DEPARTMENT OF : INFORMATION TECHNOLOGY
NAME OF THE LABORATORY : ES & IOT ________
Name B. Mahalaxmi________ Roll No. 1602-18-737-080 Page No. _11 .

EXPERIMENT-6:
Aim: To write a program to interface PIR sensor with Arduino Board and glow led if object
is found.
Algorithm:
Step 1: Take Arduino board, breadboard, pir sensor, led, resistor.
Step 2: Connect the boards with pir sensor and led with wires as shown.
Step 3: Move the object away from it, the bulb won’t glow. If the sensor senses the object, the object
will grow.
Step 4: Start simulation.
Step 5: stop.
Program:
Int pirsensor=0;
void setup()
{
pinMode(13, OUTPUT);
pinMode(2,INPUT);
}
void loop()
{
pirsensor=digitalRead(2);
if(pirsensor==HIGH)
{
digitalWrite(13, HIGH);
}
else
{
digitalWrite(13, LOW);
}
VASAVI COLLEGE OF ENGINEERING
AUTONOMOUS
(Affiliated to Osmania University)
Hyderabad- 500 031
DEPARTMENT OF : INFORMATION TECHNOLOGY
NAME OF THE LABORATORY : ES & IOT ________
Name B. Mahalaxmi________ Roll No. 1602-18-737-080 Page No. _12 .

delay(10);
}
Output:

Design:

Result: The program to interface PIR sensor with Arduino Board and glow LED if object is
found. is successfully executed.
VASAVI COLLEGE OF ENGINEERING
Department of Information Technology
Course: BE Semester: VI Section: B
Roll no: 1602-18-737-080 Name: B. Mahalaxmi
Name of the course: ES&IOT LAB

Aim: To write a C program to interface keyboard with microcontroller.


Algorithm:
Step 1: Start.

Step 2: Connect R1, R2, R3, R4 to P1.0, P1.1, P1.2, P1.3 and C1, C2, C3 to P1.4,
P1.5, P1.6.
Step 3: Initiate R1=R2=R3=R4=0 and C1=C2=C3=1.

Step 4: To check where a switch is closed or not. Under while loop first give R1=0;
R2=R3=R4=1 and check with C’s. If C1==0, return 1, C2==0 return 2, C3==0 return
3 and so on.
Step 5: Check with R2=0; R1=R3=R4=1, R3=0; R1=R2=R4=1, R4=0; R2=R3=R1=1 Step
6: Stop.
Program:
#include<at89x52.h>
#include<MYLIB.H> unsigned
char keyScan(void); sbit R1 =
P1 ^ 0; sbit R2 = P1 ^ 1; sbit
R3 = P1 ^ 2; sbit R4 = P1 ^ 3;
sbit C1 = P1 ^ 4; sbit C2 = P1

^ 5; sbit C3 = P1 ^ 6; sbit C4
= P1 ^ 7; void main(void) {
unsigned char key; while (1)
{

key = keyScan();
P2 = key;
msdelay(100);
}
VASAVI COLLEGE OF ENGINEERING
Department of Information Technology
Course: BE Semester: VI Section: B
Roll no: 1602-18-737-080 Name: B.Mahalaxmi
Name of the course: ES&IOT LAB

}
unsigned char keyScan(void) {
R1 = R2 = R3 = R4 = 0; // initial 0 in to the port pin-- o/p
C1 = C2 = C3 = 1; // -----> i/p port while (1) {
if ((C1 == 0) || (C2 == 0) || (C3 == 0)) {
R1 = 0; R4 = R2
= R3 = 1; if (C1
== 0) return 1;
if (C2 == 0)
return 2; if (C3
== 0) return 3;
R2 = 0; R4 = R1
= R3 = 1; if (C1
== 0) return 4;
if (C2 == 0)
return 5; if (C3
== 0) return 6;

R3 = 0; R4 = R2

= R1 = 1; if (C1
== 0) return 7; if
(C2 == 0) return
8; if (C3 == 0)
return 9; R4 = 0;
R1 = R2 = R3 = 1;
if (C1 ==
VASAVI COLLEGE OF ENGINEERING
Department of Information Technology
Course: BE Semester: VI Section: B
Roll no: 1602-18-737-080 Name: B. Mahalaxmi
Name of the course: ES&IOT LAB

0) return 10; if
(C2 == 0) return
0; if (C3 == 0)
return 12;
}
}
}
Program Output:

Design:
VASAVI COLLEGE OF ENGINEERING
Department of Information Technology
Course: BE Semester: VI Section: B
Roll no: 1602-18-737-080 Name: B. Mahalaxmi
Name of the course: ES&IOT LAB

Result:

The Assembly language program that displays digits 0-9 in 7 segmented display
has been executed successfully.
VASAVI COLLEGE OF ENGINEERING
AUTONOMOUS
(Affiliated to Osmania University)
Hyderabad- 500 031
DEPARTMENT OF : INFORMATION TECHNOLOGY
NAME OF THE LABORATORY : Embedded Systems and IoT LAB _
Name B. Mahalaxmi Roll No. 1602-18-737-080

Lab-14

Aim: Program to read the temperature and store it in cloud server


(thinkspeak).

Algorithm:
Step 1: Start.
Step 2: Create a channel in thinkspeak and note the “write API Key”.
Step 3: Take a circuit consists of temperature sensor, WIFI module (ESP8266)
and Arduino board.
Step 4: Connect the modules using wires.
Step 5: In the string url give API key and start simulation.
Step 6: Stop.

Output:
VASAVI COLLEGE OF ENGINEERING
AUTONOMOUS
(Affiliated to Osmania University)
Hyderabad- 500 031
DEPARTMENT OF : INFORMATION TECHNOLOGY
NAME OF THE LABORATORY : Embedded Systems and IoT LAB _
Name B. Mahalaxmi Roll No. 1602-18-737-080

Result: Program to read the temperature and store it in cloud server


(thinkspeak) is successfully executed.
VASAVI COLLEGE OF ENGINEERING
AUTONOMOUS
(Affiliated to Osmania University)
Hyderabad- 500 031
DEPARTMENT OF : INFORMATION TECHNOLOGY
NAME OF THE LABORATORY : Embedded Systems and IoT LAB _
Name B. Mahalaxmi______ Roll No. 1602-18-737-080 Page No. 1 .

WEEK-15
EXPERIMENT-1:
AIM:
Adding two Numbers.

ALGORITHM:

1. Start
2. Initialize num1, num2 with 0x0000aaaa, 0x0000bbbb
3. Load register R1 with num1.
4. Load register R2 with num2.
5. Load value of R1 into register R3.
6. Load value of R2 into register R4.
7. Add the numbers present in R3, R4 and store the number in R5.

PROCEDURE FOR EXECUTION:

1. Write the code in editor mode in simulator.


2. Save the code here
3. Click on Run->Assemble
4. Then click the run button in Execute tab.
5. Check the values in Registers table

PROGRAM:

.arm
.data
sum: .word
num1: .word 0x0000aaaa
num2: .word 0x0000bbbb
.text
.global main @ 'main' function is mandatory.

main:
ldr r1, =num1
VASAVI COLLEGE OF ENGINEERING
AUTONOMOUS
(Affiliated to Osmania University)
Hyderabad- 500 031
DEPARTMENT OF : INFORMATION TECHNOLOGY
NAME OF THE LABORATORY : Embedded Systems and IoT LAB _
Name B. Mahalaxmi______ Roll No. 1602-18-737-080 Page No. 2 .

ldr r2, =num2


ldr r3, [r1]
ldr r4, [r2]
add r5, r3, r4
ldr r6, =sum
str r5, [r6]

OUTPUT:
VASAVI COLLEGE OF ENGINEERING
AUTONOMOUS
(Affiliated to Osmania University)
Hyderabad- 500 031
DEPARTMENT OF : INFORMATION TECHNOLOGY
NAME OF THE LABORATORY : Embedded Systems and IoT LAB _
Name B. Mahalaxmi______ Roll No. 1602-18-737-080 Page No. 3 .

RESULT:
Program executed successfully.
VASAVI COLLEGE OF ENGINEERING
AUTONOMOUS
(Affiliated to Osmania University)
Hyderabad- 500 031
DEPARTMENT OF : INFORMATION TECHNOLOGY
NAME OF THE LABORATORY : Embedded Systems and IoT LAB _
Name B. Mahalaxmi______ Roll No. 1602-18-737-080 Page No. 4 .

EXPERIMENT-2
AIM:
Write a program to add elements in an array
ALGORITHM:

1. Start
2. Create an array of numbers
3. Initialize a counter register to the number of elements in an array
4. Load base address of an array to a register.
5. Load value to a temporary register
6. Add and store number in destination register
7. Decrement counter value
8. Repeat steps 5-7 till counter value becomes zero
9. Stop.

PROCEDURE FOR EXECUTION:

1. Write the code in editor mode in simulator.


2. Save the code here
3. Click on Run->Assemble
4. Then click the run button in Execute tab.
5. Check the values in Registers table

PROGRAM:
.arm

.data
numarray: .word 1,2,3,4,5,6,7,8,9
sum: .word

.text
.global main @ 'main' function is mandatory.

main:
mov r0, #9 @ Set loop counter to 0
mov r1, #0 @ Set initial sum value to 0;
VASAVI COLLEGE OF ENGINEERING
AUTONOMOUS
(Affiliated to Osmania University)
Hyderabad- 500 031
DEPARTMENT OF : INFORMATION TECHNOLOGY
NAME OF THE LABORATORY : Embedded Systems and IoT LAB _
Name B. Mahalaxmi______ Roll No. 1602-18-737-080 Page No. 5 .

ldr r2, =numarray @ r2 = &numarray


.Lloop:
ldr r3, [r2], #4 @ r3 = *r2; r2=r2+4
add r1, r1, r3 @ sum = sum + numarray[i]
subs r0, r0, #1 @ Decrement loop counter
bne .Lloop @ Branch back if the loop counter i!=0
ldr r0, =sum @ r0 = &sum; Reuse register r0
str r1, [r0] @ *r0 = r1 (sum = r1)

OUTPUT:
VASAVI COLLEGE OF ENGINEERING
AUTONOMOUS
(Affiliated to Osmania University)
Hyderabad- 500 031
DEPARTMENT OF : INFORMATION TECHNOLOGY
NAME OF THE LABORATORY : Embedded Systems and IoT LAB _
Name B. Mahalaxmi______ Roll No. 1602-18-737-080 Page No. 6 .

RESULT:
Program executed successfully.
VASAVI COLLEGE OF ENGINEERING
AUTONOMOUS
(Affiliated to Osmania University)
Hyderabad- 500 031
DEPARTMENT OF : INFORMATION TECHNOLOGY
NAME OF THE LABORATORY : Embedded Systems and IoT LAB _
Name B. Mahalaxmi______ Roll No. 1602-18-737-080 Page No. 7 .

EXPERIMENT-3
Aim:
Program to execute forward branch

ALGORITHM:

1. Start

2. Move first value to R3

3. Move second value to R4

4. Compare the Registers R3 and R4

5. Subtract registers R1 and R2 from R0

6. Exit

7. Stop

PROCEDURE FOR EXECUTION:

1. Write the code in editor mode in simulator.


2. Save the code here
3. Click on Run->Assemble
4. Then click the run button in Execute tab.
5. Check the values in Registers table

PROGRAM:

.text
.global main
main:
mov r3, #10
mov r4, #11
cmp r3, r4
ble .Lif
sub r0, r1, r2
VASAVI COLLEGE OF ENGINEERING
AUTONOMOUS
(Affiliated to Osmania University)
Hyderabad- 500 031
DEPARTMENT OF : INFORMATION TECHNOLOGY
NAME OF THE LABORATORY : Embedded Systems and IoT LAB _
Name B. Mahalaxmi______ Roll No. 1602-18-737-080 Page No. 8 .

b .Lexit
.Lif: add r0, r1, r2
.Lexit:

OUTPUT:
VASAVI COLLEGE OF ENGINEERING
AUTONOMOUS
(Affiliated to Osmania University)
Hyderabad- 500 031
DEPARTMENT OF : INFORMATION TECHNOLOGY
NAME OF THE LABORATORY : Embedded Systems and IoT LAB _
Name B. Mahalaxmi______ Roll No. 1602-18-737-080 Page No. 9 .

RESULT:
program executed successfully.

EXPERIMENT-4:
Aim: To write a program to show output of sum of squares
Algorithm:

1. Start.
2. Initialize the array size and load it in R0.
3. Create an array of numbers.
4. Initialize a variable sqrsum with 0.
5. Initialize a Register R3 with 0.
6. Load base address of an array to a register R1.
7. Start Loop

7.1 if value in R0 is 0 then go to step 8 else continue the remaining steps.

7.2 Increment the base address and load it in register R2.


VASAVI COLLEGE OF ENGINEERING
AUTONOMOUS
(Affiliated to Osmania University)
Hyderabad- 500 031
DEPARTMENT OF : INFORMATION TECHNOLOGY
NAME OF THE LABORATORY : Embedded Systems and IoT LAB _
Name B. Mahalaxmi______ Roll No. 1602-18-737-080 Page No. 10 .

7.3 Square the number present in R2 and add it to R3.

7.4 Decrement R0 by 1.

7.5 Go to step 7

PROCEDURE FOR EXECUTION:

1. Write the code in editor mode in simulator.


2. Save the code here
3. Click on Run->Assemble
4. Then click the run button in Execute tab.
5. Check the values in Registers table

PROGRAM:
.arm
.data
arraysize: .word 10
array: .word 1, -2, 3, -4, 5, -6, 8, -7, 9, -10
sqrsum: .word 0

.text
.global main @ 'main' function is mandatory.

@ r0 = arraysize; r1 = &array; r3 = sum; r2 = array[i]


@ Other Registers Used: r6, r7

main:
ldr r0, =arraysize @ r0 = &arraysize
ldr r0, [r0] @ r0 = arraysize. We are immediately reusing r0.
ldr r1, =array @ r1 = &array
mov r3, #0 @ r3 = 0 (sum = 0)
cmp r0, #0 @ if (r0 == 0) goto exit;
beq .Lexit

@ We are using r0 as a loop index variable

.Lloop: ldr r2, [r1], #4


VASAVI COLLEGE OF ENGINEERING
AUTONOMOUS
(Affiliated to Osmania University)
Hyderabad- 500 031
DEPARTMENT OF : INFORMATION TECHNOLOGY
NAME OF THE LABORATORY : Embedded Systems and IoT LAB _
Name B. Mahalaxmi______ Roll No. 1602-18-737-080 Page No. 11 .

mla r3, r2, r2, r3 @ r3 = r2*r2+r3 (sum = sum + array[i]*array[i])


subs r0, r0, #1
bne .Lloop
ldr r6, =sqrsum @ r6 = &sqrsum
str r3, [r6] @ *r6 = r3
.Lexit:

OUTPUT:
VASAVI COLLEGE OF ENGINEERING
AUTONOMOUS
(Affiliated to Osmania University)
Hyderabad- 500 031
DEPARTMENT OF : INFORMATION TECHNOLOGY
NAME OF THE LABORATORY : Embedded Systems and IoT LAB _
Name B. Mahalaxmi______ Roll No. 1602-18-737-080 Page No. 12 .

RESULT:
Program executed Successfully.

You might also like