LIST OF THE EXPERIMENTS
Exp Experiments Name Page
No No
1
Write 8051 Assembly Language experiments using
simulator.
2 Test data transfer between registers and memory.
3
Perform ALU operations.
4
Write Basic and arithmetic Programs Using Embedded C.
5
Introduction to Arduino platform and programming
6
Explore different communication methods with IoT devices
(Zigbee, GSM, Bluetooth)
7
Introduction to Raspberry PI platform and python
programming
8
Interfacing sensors with Raspberry PI
9
Communicate between Arduino and Raspberry PI using any
wireless medium
10
Setup a cloud platform to log the data
11 Log Data using Raspberry PI and upload to the cloud platform
12 Design an IOT based system Smart Lock System
1
Ex.No:2a Data transfer programming using Assembly language
Aim:
To perform data transfer between registers and memory using 8051 Assembly
language.
Software required:
• Keil μvision 5
Procedure:
• Here, 5 bytes of data transfer from memory location 30h to 40h.
• Move the 30h value to register R0. It is referred as source address.
• Move the 40h value to register R1. It is referred as destination address.
• Move the 5h value to register R7. It is referred as five bytes of data transfer from
memory location 30h to 40h.
• Move the 27h, 35h, 42h, 67h, & 98h value to memory location from 30h to 34h
respectively.
• Finally, 5 bytes of data transferring from memory location 30h - 34h to 40h – 44h
respectively, using djnz (decremented jump if not equal to zero) loop.
Data transfer Assembly language program:
mov r0, #30h // source address
mov r1, #40h // destination address
mov r7, #05h // Number of bytes to be moved
mov 30h, #27h // Value 27h move into memory
location 30h
2
mov 31h, #35h // Value 35h move into memory
location 31h location 31h
mov 32h, #42h // Value 42h move into memory
location 32h
3
mov 33h, #67h // Value 67h move into memory
location 33h
mov 34h, #98h // Value 98h move into memory
location 34h
back: // 5 bytes of data
mov a, @r0 transferring from
location 30h to 40h
mov @r1, a
inc r0
inc r1
djnz r7, back // repeat till all data transferred
end
Output:
Before Data Transfer After Data Transfer
Result:
Thus, the data transfer between registers and memory was successfully
compiled and executed.
4
Ex. No:
2b Data Exchange programming using Assembly language
Aim:
To perform data exchange between registers and memory using 8051
Assembly language.
Software required:
• • Keil μvision 5
Procedure:
• Here, 5 bytes of data exchanging between memory location 30h to 40h.
• Move the 30h value to register R0. It is referred as source address.
• Move the 40h value to register R1. It is referred as destination address.
• Move the 5h value to register R7. It is referred as five bytes of data transfer from
memory location 30h to 40h.
• Move the 27h, 35h, 42h, 67h, & 98h value to memory location from 30h to 34h
respectively.
• Move the 74h, 83h, 29h, 16h, & 11h value to memory location from 40h to 44h
respectively.
• Finally, 5 bytes of data exchanging between memory location 30h – 34h to 40h –
44h respectively, using djnz (decremented jump if not equal to zero) loop.
Data exchange Assembly language program:
mov r0, #30h // source address
mov r1, #40h // destination address
mov r7, #05h // count, the number of data to be
5
exchanged
mov 30h, #27h // Value 27h move into memory location
30h
mov 31h, #35h // Value 35h move into memory location
31h
mov 32h, #42h // Value 42h move into memory location
32h
mov 33h, #67h // Value 67h move into memory location
33h
mov 34h, #98h // Value 98h move into memory location
34h
mov 40h, #74h // Value 74h move into memory location
40h
mov 41h, #83h // Value 83h move into memory location
41h
mov 42h, #29h // Value 29h move into memory location
42h
mov 43h, #16h // Value 16h move into memory location
43h
mov 44h, #11h // Value 11h move into memory location
44h
back: // 5 bytes of data
exchanging from memory
mov a, @r0 location 30h to 40h
mov r4, a
mov a, @r1
6
mov @r0, a
mov a, r4
mov @r1, a
inc r0
inc r1
djnz r7, back
end
Output:
Before Data Transfer After Data Transfer
Result:
Thus, the data exchange between registers and memory was successfully
compiled and executed
7
Ex. No:
3a 16-bit Addition using Assembly language
Aim:
To perform the arithmetic operation of 16-bit subtraction using 8051
Assembly language.
Software required:
• • Keil μvision 5
Procedure:
• Take two 16-bit hexadecimal numbers and place it into four registers.
• Store the 1st 16-bit number in R1, R0 with MSB and LSB respectively.
• Store the 2nd 16-bit number in R3, R2 with MSB and LSB respectively.
• Subtract the lower order bytes and store it in internal memory addresses.
• Subtract the higher order bytes and store it in internal memory addresses.
• Now the result will be stored in two consecutive internal memory addresses
16-bit Addition Assembly language Program:
mov r0, #34h // lower nibble of No.1
mov r1, #12h // higher nibble of No.1
8
mov r2, #0dch
//lower nibble of No:2
mov r3, #0feh // higher nibble of No.2
clr c
mov a, r0 // Addition of two 16-bit numbers.
add a, r2
mov 22h, a
mov a, r0
Addc a, r3
mov 21h, a
mov 00h, c
end
16-bit Addition Output:
Result:
Thus, the arithmetic operation of 16-bit addition of 8051 microcontroller
was successfully compiled and executed.
9
Ex.
No: 16-bit Subtraction using Assembly language
3b
Aim:
To perform the arithmetic operation of 16-bit subtraction using 8051
Assembly language.
Software required:
• Keil μvision 5
Procedure:
• Take two 16-bit hexadecimal numbers and place it into four registers.
• Store the 1st 16-bit number in R1, R0 with MSB and LSB respectively.
• Store the 2nd 16-bit number in R3, R2 with MSB and LSB respectively.
• Subtract the lower order bytes and store it in internal memory addresses.
• Subtract the higher order bytes and store it in internal memory addresses.
• Now the result will be stored in two consecutive internal memory addresses.
16-bit Subtraction Assembly language
Program:
mov r0, #0dch //lower nibble of No.1
mov r1, #0feh //higher nibble of No.1
mov r2, #34h //lower nibble of No.2
mov r3, #12h //higher nibble of No.2
clr c
10
mov a, r0
subb a, r2
mov 22h, a // Subtraction of two 16-
bit numbers.
mov a, r1
subb a, r3
mov 21h, a
mov 00h, c
end
16-bit Subtraction Output:
Result:
Thus, the arithmetic operation of 16-bit subtraction of 8051 microcontroller
was successfully compiled and executed.
11
Ex. No:
3c 16-bit Multiplication using Assembly language
Aim:
To perform arithmetic operation of 16-bit multiplication of 8051
microcontroller using Assembly language.
Software required:
• Keil μvision 5
Procedure:
• Take two 16-bit hexadecimal numbers and place it into four registers.
• Store the 1st 16-bit number in R3, R2 with MSB and LSB respectively.
• Store the 2nd 16-bit number in R1, R0 with MSB and LSB respectively.
• Multiply the two lower bite registers and store it in internal memory addresses.
• Now multiply two higher bit registers and store it in internal addresses along with
adding the carry from the lower bits.
• Add the result of the multiplication and again store it in internal memory
addresses.
• Now the result will be stored in four consecutive internal memory addresses.
16-bit Multiplication Assembly language
Program:
mov r0, #34h // 5678*1234
mov r1, #12h
mov r2, #78h
mov r3, #56h
12
mov a, r0
mov b, r2
mul ab
mov
33h, a
mov r4,
b
mov a,
r0
mov b,
r3
mul ab
add a,
r4
mov r5,
a
mov a,
b
addc a,
#00h
mov r6,
a
mov a,
r1
mov b,
r2
13
mul ab
add a,
r5
mov
32h, a
mov a,
b
addc a,
r6
mov
00h,
c
mov r7,
a
mov a,
r3
mov b,
r1
mul ab
add a,
r7
mov
31h, a
mov a,
b
addc a,
20h
14
mov 30h, a
end
16-bit Multiplication Output:
Result:
Thus, the arithmetic operation of 16-bit multiplication was successfully
compiled and executed.
15
Ex. No: Logical operations using Assembly language
3d
Aim:
To perform various logical operation of 8051 microcontroller using Assembly
language.
Software required:
• Keil μvision 5
Logical operations using Assembly language
program:
mov a, #43h
mov r0, #64h
anl a, r0 // AND logic
mov 30h, a
mov a, #43h
orl a, r0 // OR logic
mov 31h, a
mov a, #43h
xrl a, r0 // XOR logic
mov 32h, a
mov a, #43h
16
cpl a // NOT logic
mov 33h, a
mov a, #43h
rr a // Rotate Right
operation
mov 34h, a
mov a, #43h
rl a // Rotate Left
operation
mov 35h, a
mov a, #43h
rrc a // Rotate Right with Carry
operation
mov 36h, a
mov a, #43h
rlc a // Rotate Left with Carry
operation
mov 37h, a
end
Logical operations
Output:
Result:
Thus, the various logical operation of 8051 microcontroller using assembly
language was compiled successfully and executed.
17
Ex. No:
4 Arithmetic operations using Embedded C
Aim:
To perform all the arithmetic operation of 8051 using Embedded C
language.
Software required:
• Keil μvision 5
Arithmetic operations using Embedded C program:
#include<reg51.h>
void main (void)
unsigned char x,y,z, a,b,c, d,e,f, p,q,r;
//addition
x=0x12;
y=0x34;
P0=0x00;
z=x+y;
P0=z;
//subtraction
a=0x12; // first 8-bit number
18
b=0x34; // second 8-bit number
P1=0x00; // declared port 1 as output
c=b-a; // perform subtraction
P1=c; // display result on port 1
//multiplication
d=0x12; // first 8-bit number
e=0x34; // second 8-bit number
P2=0x00; // declared port 2 as output
f=d*e; // perform multiplication
P2=f; // display result on port 2
//division
p=0x12; // first 8-bit number
q=0x34; // second 8-bit number
P3=0x00; // declared port 3 as output
r=q/p; // perform division
P3=r; // display result on port 3
Arithmetic Programs
Output:
Addition Output – display results on Port 0
19
Subtraction Output – display results
on Port 1
Multiplication Output – display
results on Port 2
Division Output – display results
on Port 3
20
Result:
Thus, the arithmetic operation of 8051 microcontroller was compiled
successfully and executed.
21