0% found this document useful (0 votes)
31 views47 pages

ESIOT Lab Manual Final 22.3.24

The document is a lab record for the CS3691 - Embedded Systems and IoT course at SRI Muthukumaran Institute of Technology, detailing various experiments conducted using 8051 assembly language programming and Embedded C. It includes algorithms and programs for operations like addition, subtraction, multiplication, division of hexadecimal numbers, data transfer, and bitwise operations, as well as practical applications using Arduino for controlling LEDs and buzzers. Each experiment outlines the aim, algorithm, program, and results of the execution.

Uploaded by

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

ESIOT Lab Manual Final 22.3.24

The document is a lab record for the CS3691 - Embedded Systems and IoT course at SRI Muthukumaran Institute of Technology, detailing various experiments conducted using 8051 assembly language programming and Embedded C. It includes algorithms and programs for operations like addition, subtraction, multiplication, division of hexadecimal numbers, data transfer, and bitwise operations, as well as practical applications using Arduino for controlling LEDs and buzzers. Each experiment outlines the aim, algorithm, program, and results of the execution.

Uploaded by

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

SRI MUTHUKUMARAN INSTITUTE OF

TECHNOLOGY
Chikkarayapuram, Near Mangadu, Chennai-600069

DEPARTMENT OF COMPUTER SCIENCE AND


ENGINEERING

LAB RECORD

CS3691 – EMBEDDED SYSTEMS AND IOT


(As Per Anna University Regulations 2021)

B.E - CSE-VI SEMESTER

2023-2024

1
INDEX

S.No Title of the Experiment Page No.

1.

2.

3.

4.

5.

6.

7.

8.

9.

10.

11.

2
Ex.No: 1
Date :
Addition and Subtraction of two Hexadecimal Numbers using 8051 Assembly
Language Programming
Aim :
To perform addition and subtraction of two hexa decimal numbers using 8051 assembly
Language Programming
Software Required :
1. Keil µVision Software
Program for Addition :
Algorithm:
STEP 1: Load the address of the first operand into R0
STEP 2: Load the address of the second operand into R1
STEP 3: Load the value at the address in R0 into accumulator A
STEP 4: Copy the value to register R5
STEP 5: Initialize a counter in R4 to 0
STEP 6: Load the value at the address in R1 into accumulator A
STEP 7: Add the value in accumulator A to the value in R5
STEP 8: Jump to SAVE if there is no carry (no overflow)
STEP 9: If there is a carry, increment the counter in R4
STEP 10: Move the value in R4 to the memory location pointed to by R1
STEP 11: Increment the address in R1 to point to the next location
STEP 12: Save the result (accumulator A) at the address in R1
Program:
ORG 00H
SJMP START
ORG 30H
START:
MOV R0,#20H
MOV R1,#30H
MOV A,@R0
MOV R5,A
MOV R4,#00H

3
INC R0
MOV A,@R1
ADD A,R5
JNC SAVE
INC R4
MOV B,R4
MOV @R1,B
INC R1
SAVE: MOV @R1,A
HALT: SJMP HALT
END

Execution :

Before Execution:

4
After Execution :

5
Program for Subtraction:
Algorithm:
STEP 1: Load the address of the first operand into R0
STEP 2: Load the address of the second operand into R1
STEP 3: Load the value at the address in R0 into accumulator A
STEP 4: Copy the value to register R5
STEP 5: Initialize a counter in R4 to 0
STEP 6: Load the value at the address in R1 into accumulator A
STEP 7: Subtract the value in accumulator A to the value in R5
STEP 8: Jump to SAVE if there is no borrow (no overflow)
STEP 9: If there is a carry, increment the counter in R4
STEP 10: Move the value in R4 to the memory location pointed to by R1
STEP 11: Increment the address in R1 to point to the next location
STEP 12: Save the result (accumulator A) at the address in R1
Program:
ORG 00H
SJMP START
ORG 30H
START:
MOV R0, #20H
MOV R1, #30H
MOV A, @R0
MOV R5, A
MOV R4, #00H
INC R0
MOV A, @R1
SUB A, R5
JNC SAVE
INC R4
MOV B, R4
MOV @R1, B
INC R1

6
SAVE: MOV @R1, A
HALT: SJMP HALT
END
Execution :

Before Execution:

7
After Execution :

Results:
Thus the addition and subtraction of hexadecimal numbers is performed using
simulator software Keil µVision.

8
Ex.No: 2
Date :
Multiplication and Division of two Hexadecimal Numbers using 8051 Assembly
Language Programming
Aim :
To perform multiplication and division. of two hexa decimal numbers using 8051
assembly Language Programming
Algorithm:
STEP 1: Initialize Address of the first hexadecimal number
STEP 2: Initialize Address of the second hexadecimal number
STEP 3: Initialize Address to store the result
STEP 4: Clear accumulator A
STEP 5: Clear register B
STEP 6: Initialize Outer loop for the first hexadecimal number
STEP 7: Initialize Counter for the inner loop
STEP 8: Load a byte from the first hexadecimal number
STEP 9: Copy to carry for rotation
STEP 10: Load a byte from the second hexadecimal number
STEP 11: Multiply A and B (B holds the first number)
STEP 12: Add the previous value in @R2 to the result
STEP 13: Store the result back in memory
STEP 14: Move to the next memory location
STEP 15: Move to the next byte of the second number
STEP 16: Decrement inner loop counter and repeat if not zero
STEP 17: Move to the next byte of the first number
STEP 18: Check if the outer loop counter is zero, if not, repeat
STEP 19: End the program with an infinite loop
Program:
MOV R0, #20H
MOV R1, #30H
MOV R2, #40H
MOV A, #00H
MOV B, #00H
OUTER_LOOP:
MOV R3, #04H

9
INNER_LOOP:
MOV A, @R0
MOV C, A
MOV A, @R1
MUL AB
ADD A, @R2
MOV @R2, A
INC R2
INC R1
DJNZ R3, INNER_LOOP
DEC R0
JNZ OUTER_LOOP
END
Before Execution:

10
After Execution:

Division of two numbers


Algorithm:
STEP 1: Set the origin address
STEP 2: Initialize data pointer to the data section
STEP 3: Load the first byte of the dividend from memory location 0x0030
STEP 4: Store it in R0
STEP 5: Move to the next byte in the data section
STEP 6: Load the second byte of the dividend from memory location 0x0031
STEP 7: Move to the memory location 0x0032 (divisor)
STEP 8: Load the divisor from memory location 0x0032
STEP 9: Store it in R1
STEP 10: Divide the 16-bit number in R0 and R1 by the divisor in R1

11
STEP 11: Quotient is stored in R2
STEP 12: Remainder is stored in R3
STEP 13: our result is now in R2 (quotient) and R3 (remainder)
Program
ORG 0x0000
MOV DPTR, #0x0030
MOVX A, @DPTR
MOV R0, A
INC DPTR
MOVX A, @DPTR
INC DPTR
MOVX A, @DPTR
MOV R1, A
DIV AB
MOV R2, A
MOV R3, B
END

12
13
After Execution :

Result:
Thus the Multiplication and subtraction of hexadecimal numbers is performed using
simulator software Keil µVision.

14
Ex.No: 3
Date :
Test the data transfer between Data and Memory using 8051 Assembly
Language Programming
Aim :
To test the data transfer between data and memory using 8051 assembly Language Programming
Algorithm:
STEP 1: Set the origin address
STEP 2: Load a byte of data into register A
STEP 3: Set the destination memory location (replace with your desired memory location
STEP 4: Store the data in the specified memory location
STEP 5: Set the source memory location
STEP 6: Load the data from the specified memory location into register A
STEP 7: Register A contains the data that was transferred from memory

Program
ORG 0x0000
MOV A, #0x55
MOV DPTR, #0x0030
MOVX @DPTR, A
MOV DPTR, #0x0030
MOVX B, @DPTR
END

15
Before Execution:

After Execution:

Result:
Thus the transfer of data is performed using Keil µVision simulator software.

16
17
Ex.No: 4
Date :
Program on performing AND, OR and XOR operations on Hexa Decimal
Numbers Aim :
To test the data transfer between data and memory using 8051 assembly Language Programming
Program to perform AND operation on HexaDecimal Numbers
Algorithm:
STEP 1: Initialize Starting address of the program
STEP 2: Load the first 8-bit number (37H in hexadecimal) into register R1
STEP 3: Load the second 8-bit number (15H in hexadecimal) into register R2
STEP 4: Move the content of register R1 to the accumulator A
STEP 5: Perform bitwise AND operation with the content of Register R2
STEP 6: Store the result in REGISTER
STEP 7: End of the program
Program:
ORG 0H
MOV R1, #37H
MOV R2, #15H
MOV A, R1
ANL A, R2
MOV R0, A
END

18
Before Execution:

After Execution:

19
Program to perform OR operation on HexaDecimal Numbers
Algorithm:
STEP 1: Initialize Starting address of the program
STEP 2: Load the first 8-bit number (37H in hexadecimal) into register R1
STEP 3: Load the second 8-bit number (15H in hexadecimal) into register R2
STEP 4: Move the content of register R1 to the accumulator A
STEP 5: Perform bitwise OR operation with the content of Register R2
STEP 6: Store the result in REGISTER
STEP 7: End of the program

Program:

ORG 0H
MOV R1, #37H
MOV R2, #15H
MOV A, R1
ORL A, R2
MOV R0, A
END

Before Execution:

20
After Execution:

Program to perform XOR operation on HexaDecimal Numbers


Algorithm:
STEP 1: Initialize Starting address of the program
STEP 2: Load the first 8-bit number (37H in hexadecimal) into register R1
STEP 3: Load the second 8-bit number (15H in hexadecimal) into register R2
STEP 4: Move the content of register R1 to the accumulator A
STEP 5: Perform bitwise XOR operation with the content of Register R2
STEP 6: Store the result in REGISTER R0
STEP 7: End of the program
Program:
ORG 0H
MOV R1, #37H
MOV R2, #15H
MOV A, R1
XRL A, R2
MOV R0, A
END

21
Before Execution:

After Execution:

Result:
Thus the Bit wise Boolean operations are performed on the Hexadecimal data using
Keil µVision Software.

22
Ex.No: 5
Date :
Program on Addition, Subtraction and Multiplication of two hexadecimal numbers using
Embedded C
Aim:
To write a program to add, subtract and multiply two hexadecimal numbers using Embedded C.
Program:
#INCLUDE <reg51.h>
void main()
{
unsigned int i,j;
i=0x89;
j=0x23;
P0=i+j;
P1=i-j;
P2=i*j;
}
Before Execution:

23
After Execution:

Result:
Thus the program is written to add, subtract and multiply two hexadecimal numbers
using embedded C.

24
Ex.No: 6
Date :

Program to find sum of first ten numbers using Embedded C


Aim :
To write a program to find the sum of first 10 numbers using Embedded C.
Program:
void main() {
unsigned int i;
unsigned int sum = 0;
for (i = 1; i <= 10; i++)
{
sum += i;
}
P0 = sum;
while (1) {
}
}
Before Execution:

25
After Execution:

26
Result :
Thus the sum of first 10 numbers has been calculated using embedded C.

27
Ex.No: 7
SMALLEST AND LARGEST NUMBER IN AN ARRAY
Date :

Aim :
To find the smallest and largest number in an array.
Largest Number in an array:
#include <reg51.h>
#define ARRAY_SIZE 6
void main()
{
unsigned char array[ARRAY_SIZE] = {0x25, 0x55, 0x13, 0x62, 0x0A,
0xFF}; unsigned char largest = array[0];
unsigned char smallest =
array[0]; unsigned char i;
for (i = 1; i < ARRAY_SIZE; i++)
{
if (array[i] > largest)
{
largest = array[i];
}

if (array[i] < smallest)


{
smallest = array[i];
}
}
P0 = largest;
P1 = smallest;
while (1)
{
}
}

28
Before Execution:

29
After Execution:

30
Result :
Thus the largest and smallest number of an array is found using Keil µVision Software.

31
Ex.No: 8
LED CONTROL USING AURDUINO
Date :

Aim :
To control LED using Arduino board.
Apparatus Required:
S.No Apparatus Quantity
1. Arduino Board 1
2. Bread Board 1
3. LED 1
4. Power Jack 1
5. USB Cable 1
6. Jumper wires As Required

Circuit Connection:

Hardware Procedure:
32
(i) LED pin is Connected to Arduino Uno pin of 2.
(ii) Power jack is connected to the Arduino Uno.
(iii) USB connector is connected to Arduino Uno to monitor.
(iv) Connect the 12V power supply to development board.
(v) Check the output from the development board.
Software Procedure:
(i) Click on Arduino IDE
(ii) Click on file
(iii)Click on New
(iv) Write a Program as per circuit Pin connections
(v) Click on Save
(vi)Click on Verify
(vii)Click on Upload the code into Arduino Uno by using USB cable.
Program:
void setup()
{
pinMode(8,OUTPUT);
}
void loop()
{
digitalWrite(8,HIGH);
delay(1000);
digitalWrite(8,LOW);
delay(1000);
}

Result :
LED is successfully controlled using Arduino microcontroller board

33
Ex.No: 9 INTERFACING BUZZER ALARM WITH ARDUINO
Date :

Aim :
To interface a buzzer with Arduino board
Apparatus Required:
S.No Apparatus Quantity
1. Arduino Board 1
2. Bread Board 1
3. LED 1
4. Power Jack 1
5. USB Cable 1
6. Resistor (100 Ω) 1
7. Jumper wires As Required

Connection Setup for interfacing Arduino with buzzer:

34
Hardware Procedure:
(i) Positive pin of Buzzer is Connected to Arduino Uno pin of 12. Negative pin
is connected to ground.
(ii) Power jack is connected to the Arduino Uno.
(iii) USB connector is connected to Arduino Uno to monitor.
(iv) Connect the 12V power supply to development board.
(v) Check the output from the development board.
Software Procedure:
(i) Click on Arduino IDE
(ii) Click on file
(iii) Click on New
(iv) Write a Program as per circuit Pin connections
(v) Click on Save
(vi) Click on Verify
(vii) Click on Upload the code into Arduino Uno by using USB cable.
Program:
void setup() {
pinMode(7, OUTPUT);
}
void loop()
{
tone(7, 220, 100);
delay(200);
}

Result :
Thus the buzzer sound is produced using Buzzer device and Arduino.

35
Ex.No: 10 INTERFACING BLUETOOTH HC-05 WITH ARDUINO
Date :

Aim :
To interface a Bluetooth with Arduino board
Apparatus Required:
S.No Apparatus Quantity
1. Arduino Board 1
2. Bread Board 1
3. LED 1
4. Power Jack 1
5. USB Cable 1
6. Resistor (100 Ω) 1
7. Bluetooth HC - 05 1
7. Jumper wires As Required

Circuit Connections:

Hardware Procedure:
(i) Connections are given as per the circuit above
(ii) Power jack is connected to the Arduino Uno.
(iii) USB connector is connected to Arduino Uno to monitor.
(iv) Connect the 12V power supply to development board.
(v) Check the output from the development board.
Software Procedure:
(i) Click on Arduino IDE

36
(ii) Click on file
(iii) Click on New
(iv) Write a Program as per circuit Pin connections
(v) Click on Save
(vi) Click on Verify
(vii) Click on Upload the code into Arduino Uno by using USB cable.
(viii) Download Bluetooth serial controller APP from Google Play
(ix) Send Data as “A” or “B” from the App
Program :
int led=13;
int data;
void setup()
{
serial. begin (9600);
pinmode(13, OUTPUT);
}
Void loop()
{
While ( serial.available () > 0)
{
Data=serial. read()
Serial. println(data)
If (data == ‘A’)
{
digitalwrite(13, HIGH);
}
If (data == ‘B”)
{
Digitalwrite (13, LOW);
}
}
}

Result:
Thus the message from mobile is transferred to Bluetooth through Arduino.

37
Ex.No: 10 INTRODUCTION TO RASPBERRY PI PLATFORM AND PYTHON
PROGRAMMING
Date :

Aim :
To introduce about the Raspberry Pi board and programming Raspberry Pi in python
Introduction to Raspberry Pi:

USB Port – Used to connect a mouse and a keyboard


SD Card Slot – SD Card can be slotted here
Ethernet Port – Used to connect Raspberry Pi with the network through the
cable Audio Jack – Can connect headphones and speakers
HDMI Port – the monitor (or projector) can be connected to display the output from Raspberry
Pi.
Micro USB Power Connector – Power Supply is connected here
GPIO Ports – Allows us to connect electronic components such as LEDs and buttons
to Raspberry Pi.
Setting up our SD Card:

38
 The Raspberry Pi imager is an easiest way to install the Raspberry Pi OS.
 The Raspberry Pi imager software is available in Raspberry Pi Downloads Page
 Insert the SD Card into the computer or SD Card Slot.
 Install the Raspberry Pi Imager software in the SD Card.
Connecting our Raspberry Pi:
 The slot for SD Card is available in the underside of the Raspberry Pi.
 Connect the mouse and keyboard through the USB Slots.
Starting Up Raspberry Pi
 The Plug the power supply into the socket and connect it to Raspberry Pi Power Port.
 A red LED Light lights up in Rasp Berry Pi indicating that Raspberry Pi is connecte
to power.
 After few seconds the raspberry Pi OS Desktop will appear.
Finishing the set up:
 When we start the Raspberry Pi for the first time, the Welcome to Raspberry
Pi application will pop – up and will guide through the entire set up.
 Click Next to start the setup.
 Set your Country, Language and Time zone, then click next again.
 Enter the new password for your Raspberry Pi and click next.
 Connect to your WiFi Network by selecting its name, entering the password and
clicking next.
 Click next for the wizard check for updates to Raspbian and install them .
 Click done or reboot to finish the setup.

Introduction to Python
Python is a computer programming language often used to build websites and software,
automate tasks, and conduct data analysis. Python is a general-purpose language, meaning it can
be used to create a variety of different programs and isn’t specialized for any specific problems.
This versatility, along with its beginner-friendliness, has made it one of the most-used
programming languages today.
Python is commonly used for developing websites and software, task automation, data analysis,
and data visualization. Since it’s relatively easy to learn, Python has been adopted by many non-
programmers such as accountants and scientists, for a variety of everyday tasks, like organizing
finances.
Python finds its applications in the fields of :
 Data analysis and machine learning

39
 Web development
 Automation or scripting
 Software testing and prototyping
 Everyday tasks

Reason for Popularity of python :


Python is popular for a number of reasons. Here’s a deeper look at what makes it so versatile and
easy to use for coders.
 It has a simple syntax that mimics natural language, so it’s easier to read and understand.
This makes it quicker to build projects, and faster to improve on them.
 It’s versatile. Python can be used for many different tasks, from web development to
machine learning.
 It’s beginner friendly, making it popular for entry-level coders.
 It’s open source, which means it’s free to use and distribute, even for commercial purposes.
 Python’s archive of modules and libraries—bundles of code that third-party users have
created to expand Python’s capabilities—is vast and growing.
 Python has a large and active community that contributes to Python’s pool of modules
and libraries, and acts as a helpful resource for other programmers. The vast support
community means that if coders run into a stumbling block, finding a solution is
relatively easy; somebody is bound to have encountered the same problem before.

Result :
Thus a brief introduction to Raspberry Pi Platform and python programming is seen.

40
Ex.No: 11
Date :

Interfacing light sensor with Raspberry Pi


Aim :
To monitor the surrounding light intensity using light sensors and Raspberry Pi
Apparatus Required:
S.No Apparatus Quantity
1. Raspberry Pi Board 1
2. Bread Board 1
3. Photocell 1
4. Resistor (1 kΩ) 1
5. Capacitor (1 µF) 1

Circuit Connection:

Hardware Connections:
 Insert the photocell in the breadboard.
 Connect the GPIO pin 1 (3.3 V) to the resistor which is connected serial to the photocell.
 Connect the other end of the photocell to the GPIO pin 12 and the capacitor as shown
in the diagram above.
 GPIO pin 6 (ground) is connected to the other end of the capacitor (short end).

41
Code:
Import RPi. GPIO as
GPIO.tie.os DEBUG = 1;
GPIO.setmode (GPIO.BOARD)
GPIO.setwarnings(False)
def RCTime(RCpin):
reading = 0
GPIO.setup(RCpin.GPIO.OUT)
GPIO.output(RCpin.GPIO.LOW)
Time.sleep(2)
GPIO.setup(RCpin.GPIO.IN)
While(GPIO.input(RCpin) ==GPIO.LOW);
Reading+=1
Return reading
While true:
Print RCTime(12)
Output:
1. With Light:

42
2. Without Light

Result :
Thus the experiment on the sensing of light with the help of Raspberry Pi is done.

43
Ex.No: 12
Date :

Soil Moisture Sensing using Arduino and Soil Moisture Sensor


Aim :
To develop a mini project on soil moisture sensing with soil moisture sensor and Arduino.
Apparatus Required:
S.No Apparatus Quantity
1. Arduino Board 1
2. Soil moisture sensor(EC1258) 1
3. LCD Display 1
4. Resistor (1 kΩ) 1
5. Capacitor (1 µF) 1

Circuit Connection:

44
Code:
#include <LiquidCrystal.h>

const int LM35 = A0;


const int motor = 13;
const int LedRed = 12;
const int LedGreen = 11;
int percentValue = 0;

LiquidCrystal lcd(2, 3, 4, 5, 6, 7);

void setup() {
Serial.begin(9600);
lcd.begin(16, 2);
lcd.print("Automated Crop");
lcd.setCursor(0,1);
lcd.print("Watering System!");
pinMode(motor, OUTPUT);
pinMode(LedRed, OUTPUT);
pinMode(LedGreen, OUTPUT);
delay(2000);
lcd.clear();
lcd.print("SoilM = ");
lcd.setCursor(0,1);
lcd.print("WaterPump= ");
}

45
void loop() {

int value = analogRead(LM35);


float Moisture = value * 500.0 /
1023.0; lcd.setCursor(6,0);
lcd.print(Moisture);
lcd.setCursor(11,1);

if (Moisture < 310){


digitalWrite(motor, HIGH);
digitalWrite(LedRed, HIGH);
digitalWrite(LedGreen, LOW);
lcd.print("ON ");
}
else {
digitalWrite(motor, LOW);
digitalWrite(LedRed, LOW);
digitalWrite(LedGreen, HIGH);
lcd.print("OFF");
}

Serial.print ("Moisture");
Serial.println (Moisture);
}

46
Output:

Result :
Thus this mini project of soil moisture sensing is done with the help of soil moisture sensor
and Arduino microcontroller.

47

You might also like