Embedded lab manual
Embedded lab manual
MELVISHARAM- 632509
LAB MANUAL
CS3691
EMBEDDED SYSTEMS AND IOT (R-2021)
Sixth Semester
PREPARED BY
Ms. CHANDRIKA G
Ms. G. DIVYA
Assistant professor / ECE
INDEX
EXP Pg. Staff
Date Name of the experiment Mark
NO. No. Sign
17. IR SENSOR 40
18 BUZZER 42
ANNEXURE
Ex No:1
8 BIT USING ARITHMETIC OPERATION 8051
Date
MICROCONTROLLER (USING SIMULATOR)
AIM:
1
FLOW CHART
2
MEMORY
OPCODES LABEL PROGRAM COMMENDS
LOCATION
Addition program
ORG 0H
Subtraction program
ORG 0H
Multiplication program
ORG 0H
3
MEMORY
LOCATION OPCODES LABEL PROGRAM COMMENDS
Division program
ORG 0H
INPUT OUTPUT
ADDITION
ACC R0
B Reg
SUBTRACTION
ACC R1
B Reg
MULTIPLICATION
ACC R3
B Reg R4
DIVISION
ACC R3
B Reg R4
Result:
Thus the 8051 ALP for Addition, Subtraction, Multiplication and Division of two 8bit numbers is
executed.
4
Ex No:2 LOGICAL OPERATIONS AND 2’S COMPLEMENT USING 8051
Date MICROCONTROLLER (USING SIMULATOR)
AIM:
To perform logical operation using 8051 microcontroller AND, OR & EX-OR.
ALGORITHM:
5
MEMORY
OPCODES LABEL PROGRAM COMMENDS
LOCATION
OR Operation program
0000 C3 ORG 0H Clear the carry
0001 74,07 MOV A, #07 Move data to Acc
0003 44,03 ORL A, #03 OR Acc with immediate
0005 F4 MOV R1, A Move result to R1 Reg
0006 80,FE HERE: JMP $ Short jump here
6
INPUT OUTPUT
ADD
DATA1 R0
DATA 2
OR
DATA1 R1
DATA 2
XOR
DATA1 R2
DATA 2
2’s COMPLEMENT
DATA1 R3
Result:
Thus the assembly language program to perform logical operations AND, OR& EX-OR
and 2’s Complement using 8051 Performed and the result is stored.
7
Ex No:3 TEST DATA TRANSFER BETWEEN REGISTER AND MEMORY
Date
AIM:
To do test data transfer between registers and memory using instructions.
APPARATUS REQUIRED:
8052Microcontroller Emulator Software
ALGORITHM:
8
PROGRAM:
RESULT:
Thus the programs to move the value between registers and memory with 8051
microcontrollers has been written and executed.
9
Ex No:4 COMPARE 2 NUMBERS IN 8051
Date
AIM:
To write a program to compare 2numbers in 8051 using stimulator.
ALGORITHM:
PROGRAM:
ORG 0000H;
MOV A,#10H;
MOV B,#15H;
CJNE A,B,NOT_EQUAL;
SJMP END_PROGRAM;
NOT_EQUAL;
END_PROGRAM;
OUTPUT:
RESULT:
Thus, to compare 2 numbers using stimulator has been done successfully and executed.
10
Ex No:5 8 BIT ARITHMETIC OPERATION USING 8051 MICROCONTROLLER
C PROGRAMMING
Date
11
PROGRAM:
# include<reg51.h>
void main(void)
{
unsigned char x,y,z, a,b,c, d,e,f, p,q,r; //define variables
//addition
x=0x03; //first 8-bit number
//multiplication
d=0x03; //first 8-bit number
//division
p=0x03; //first 8-bit number
while(1);}
12
OUTPUT:
INPUT OUTPUT
ADDITION
DATA1 PORT 0
DATA 2
SUBTRACTION
DATA1 PORT 1
DATA 2
MULTIPLICATION
DATA1
PORT 2
DATA 2
DIVISION
DATA1 PORT 3
DATA 2
RESULT:
Thus the 8051 C – Programming for Addition, Subtraction, Multiplication and Division of two 8
bitnumbers is executed in Keil.
13
Ex No:6 TRANSFER BETWEEN 2REGISTERS IN 8051
Date
AIM:
ALGORITHM:
1. Declare two unsigned char variables to represent the source register and the destination register.
2. Assign a value to source register.
3. Transfer the data from source register to destination register by assigning the values of source
register to destination.
4. Display or use the data stored.
5. End the program.
PROGRAM:
#include<reg51.h>
Void main()
{
unsigned char src_reg,dest_reg;
src_reg=0x0A;
dest_reg=src_reg;
P0=dest_reg;
while(1);
}
OUTPUT:
P0=0x0A
RESULT:
Thus, writing a program for transferring data between 2registers using embedded C has been done
successfully and executed.
14
Ex No:7 ASCENDING ORDER USING EMBEDDED C
Date
AIM:
ALGORITHM:
PROGRAM:
#include<reg51.h>
int main()
{
unsigned char temp,i,j,a[5];
printf(“enter array elements:”);
for(i=0;i<5;i++){
scanf(“%d”,&a[i]);}
for(i=0;i<5;i++){
for(j=i+1;j<5;j++){
if(a[i]>a[j]){
temp=a[i];
a[i]=a[j];
a[j]=temp;}}}
printf(“array elements:”);
for(i=0;i<5;i++){
printf(“%d”,a[i]);}
return 0;`}
OUTPUT:
Enter the array elements:2 1 5 3 4
Array elements: 1 2 3 4 5
RESULT:
Thus to write a program to find the ascending order using embedded c has been done successfully and executed.
15 15
Ex No:8 COMPARE TWO NUMBER USING EMBEDDED C
Date
AIM:
ALGORITHM;
PROGRAM:
#include<reg51.h>
int main()
{
float num1,num2;
printf(“enter the first number(integer):”);
scanf(“%F”,&num1);
printf(“enter the second number (integer):”);
scanf(“%F”,&num2);
int n1,n2;
n1=num1;
n2=num2;
if((n1!=num1)||(n2!=num2))
{
printf(“Warning 1comparing only inter part\n”);}
If(n1=n2){
printf(“number are qual\n”);}
else {
if(n1<n2){
printf(“%d is bigger \n”,n2);}
else{
printf(“%d is bigger \n”,n1);
}}
16
OUTPUT:
RESULT:
Thus to write a program for comparing two numbers using embedded c has been done successfully and
executed.
17
Ex No:9 DESCENDING ORDER USING EMBEDDED C
Date
AIM:
ALGORITHM:
PROGRAM:
#include<reg51.h>
int main()
{
unsigned char temp,i,j,a[5];
printf(“enter array elements:”);
for(i=0;i<5;i++){
scanf(“%d”,&a[i]);}
for(i=0;i<5;i++){
for(j=i+1;j<5;j++){
if(a[i]<a[j]){
temp=a[i];
a[i]=a[j];
a[j]=temp;
}}}
printf(“array elements:”);
for(i=0;i<5;i++){
printf(“%d”,a[i]);}
return 0;`
}
OUTPUT:
RESULT:
Thus to write a program to find the descending order using embedded c has been done successfully
and executed.
18
Ex No:10 IDENTIFY PARTICULAR NUMBER USING EMBEDDED C
Date
AIM:
To write a program to identify particular number in the group using embedded C.
ALGORITHM:
PROGRAM:
#include <reg51.h>
#define SIZE 5
void main() {
unsigned char arr[SIZE] = {5, 2, 8, 1, 6};
unsigned char target ;
unsigned char found = 0;
unsigned char i;
printf(“enter the target number:”);
scanf(“%d”,&target);
for (i = 0; i < SIZE; i++) {
if (arr[i] == target) {
found = 1;
break; }}
if (found){
P0 = 0xFF; }
else{
P1 = 0x00; }
while (1);
}
OUTPUT:
RESULT:
Thus to write a program to find the descending order using embedded c has been done successfully
and executed.
19
Ex No:11 LOGICAL OPERTAION USING EMBEDDED C
Date
AIM;
ALGORITHM;
1. Define variables x, y, z, a, b, c, p, q.
2. Assign values to x and y.
3. Perform NOT operation: Store the result in z, Display z on Port 0.
4. Perform AND operation: Store the result in a, Display a on Port 1.
5. Perform OR operation: Store the result in b, Display b on Port 2.
6. Perform XOR operation: Store the result in c, Display c on Port 3.
7. Perform left shift operation: Store the result in p.,Display p on Port 3.
8. Perform right shift operation: Store the result in q.Display q on Port 3.
9. Enter an infinite loop (while(1)).
10. End the program.
PROGRAM:
# include<reg51.h>
void main(void)
{
unsigned char x,y,z, a,b,c,p,q; //define variables
x=0x12; //first 8-bit number
y=0x34; //second 8-bit number
P0=0x00; //declare port 0 as output port
P1=0x00; //declare port 1 as output port
P2=0x00; //declare port 2 as output port
P3=0x00; //declare port 3 as output port
z=~x; // perform NOT operation
P0=z; //display result of addition on port 0
a=x&y;//perform AND operation
P1=a;// display result of subtraction on port 1
b=x|y;// perform OR operation
P2=b;//display result of multiplication on port 2
c=x^y;//perform XOR operation
P3=c; // display result of division on port 3
p=x<<1;//perform Left shift operation
P3=p; // display result of division on port 3
q=x>>1;//perform Right shift operation
P3=q; // display result of division on port 3
while(1);
}
20
OUTPUT:
P0=0x0E
P1=0x10
P2=0x36
P3=0x26
Left shift P3=0x24
Right shift P3=0x09
RESULT:
Thus to perform a logical operation using embedded c has bee =n done successfully and executed
21
Ex No:12 SWAPPING DATA BETWEEN MEMORY AND REGISTER
Date
AIM:
To write a program to swap data between memory and register using embedded c
ALGORITHM:
1. Define variables to hold the data stored in memory and the particular register.
2. Assign values to these variables to represent the initial data.
3. Use a temporary variable to store the data from memory.
4. Copy the data from the register to memory.
5. Copy the data from the temporary variable to the register.
6. Optionally, display or use the swapped data as needed
PROGRAM:
#include <reg51.h>
void main() {
unsigned char data_in_memory = 0x12; // Data stored in memory
unsigned char data_in_register = 0x34; // Data stored in a register
// Swap data between memory and register
unsigned char temp = data_in_memory; // Store data in memory in a temporary variable
data_in_memory = data_in_register; // Store data from register in memory
data_in_register = temp; // Store data from temporary variable in register
// Display the swapped data
// Assuming P0 is used for displaying the data
P0 = data_in_memory; // Display data stored in memory
P1 = data_in_register; // Display data stored in register
while (1); // Endless loop
}
OUTPUT:
P0=0x34
P1=0x12
RESULT:
Thus to write a program to swap the data between memory and register using embedded c ahs been
done successfully and executed .
22
Ex No:13 SMALLEST NUMBER USING EMBEDDED C
Date
AIM:
ALGORITHM:
PROGRAM:
#include <8051.h>
void main() {
unsigned char numbers[] = {5, 8, 2, 10, 6, 3, 1, 9, 4, 7};
unsigned char smallest = numbers[0]; // Assume the first number is the smallest
for (unsigned char i = 1; i < 10; i++)
{
// Compare each element with the current smallest number
if (numbers[i] < smallest)
{
// Update the smallest number if a smaller number is found
smallest = numbers[i];
}
}
while (1) {
// Your main application logic here
}
}
OUTPUT:
Smallest number=1
RESULT:
Thus to find the smallest number using embedded c has been done successfully and executed ,
23
Ex No:14 ARDUINO PROGRAMMING
Date
AIM:
To study about Arduino Board and how to do programming in Arduino.
APPARATUS REQUIRED:
Arduino IDE
(Integrated DevelopmentEnvironment)
24
Installation of Arduino Software (IDE)
Step1: Downloading
25
Step 3: Extraction of Files
The process will extract and install all the required files to execute properlythe Arduino
Software (IDE)
The USB connection with the PC is necessary to program the board and not just to
power it up. The Uno and Mega automatically draw power fromeither the USB or an
external power supply. Connect the board to the computer using the USB cable. The
green power LED (labelled PWR) should go on.
Open the Arduino IDE software on your computer. Coding in the Arduinolanguage
will control your circuit.
Open a new sketch File by clicking on New.
26
Step 6: Working on an existing project
27
Step 7: Select your Arduino board.
To avoid any error while uploading your program to the board, you must select the
correct Arduino board name, which matches with the board connected to your
computer.
Go to Tools → Board and select your board.
28
To find out, you can disconnect your Arduino board and re-open the menu, the entry that
disappears should be of the Arduino board. Reconnect the boardand select that serial port.
29
A Verify
B Upload
C New
D Open
E Save
F Serial Motor
30
Step 10: Example Code (Blink a LED light)
int ledPin = 13;
void setup ( )
{
pinMode (ledPin, OUTPUT); // Declare the LED as an output
}
void loop ( )
{
digitalWrite (ledPin, HIGH); // Turn the LED on
Delay (1000); // Delay 1000 milliseconds
digitalWrite (ledPin, LOW); // Turn the led on
delay (1000); // Delay 1000 milliseconds
}
31
ARDUINO BOARDS
Arduino is a software as well as hardware platform that helps in making electronic projects. It is
an open source platform and has a variety of controllers and microprocessors. There are various types of
Arduino boards used for various purposes.
It also provides an IDE (Integrated Development Environment) project, which is based on the Processing
Language to upload the code to the physical board.
The Arduino is a single circuit board, which consists of different interfaces or parts. The board consists
of the set of digital and analog pins that are used to connect various devices and components, which we
want to use for the functioning of the electronic devices.
The Arduino board consists of sets of analog and digital I/O (Input / Output) pins, which are further
interfaced to breadboard, expansion boards, and other circuits. Such boards feature the model, Universal
Serial Bus (USB), and serial communication interfaces, which are used for loading programs from the
computers.
The Arduino UNO is a standard board of Arduino. Here UNO means 'one' in Italian. It was named as
UNO to label the first release of Arduino Software. It was also the first USB board released by Arduino.
It is considered as the powerful board used in various projects. Arduino.cc developed the Arduino UNO
board.
Arduino UNO is based on an ATmega328P microcontroller. It is easy to use compared to other boards,
such as the Arduino Mega board, etc. The board consists of digital and analog Input/Output pins (I/O),
shields, and other circuits.
The Arduino UNO includes 6 analog pin inputs, 14 digital pins, a USB connector, a power jack, and an
ICSP (In-Circuit Serial Programming) header. It is programmed based on IDE, which stands forIntegrated
Development Environment. It can run on both online and offline platforms.
32
Power USB
Arduino board can be powered by using the USB cable from your computer.
Voltage Regulator
The function of the voltage regulator is to control the voltage given to the
Arduino board and stabilize the DC voltages used by the processor and other
elements.
Crystal Oscillator
The crystal oscillator helps Arduino in dealing with time issues. The number
printed on top of the Arduino crystal is 16.000H9H. It tells us that the frequency
is 16,000,000 Hertz or 16 MHz.
33
Arduino Reset
You can reset your Arduino board, i.e., start your program from the beginning.
You can reset the UNO board in two ways. First, by using the reset button (17)
on the board. Second, you can connect an external reset button to the Arduino
pin labelled RESET (5).
Analog pins
The Arduino UNO board has six analog input pins A0 through A5. These pins
can read the signal from an analog sensor like the humidity sensor or temperature
sensor and convert it into a digital value that can be read by the microprocessor.
Main microcontroller
Each Arduino board has its own microcontroller (11). You can assume it as the
brain of your board. The main IC (integrated circuit) on the Arduino is slightly
different from board to board. The microcontrollers are usually of the ATMEL
Company. You must know what IC your board has before loading up a new
program from the Arduino IDE. This information is available on the top of the
IC..
ICSP pin
Mostly, ICSP (12) is an AVR, a tiny programming header for the Arduino
consisting of MOSI, MISO, SCK, RESET, VCC, and GND. It is often referred
to as an SPI (Serial Peripheral Interface), which could be considered as an
"expansion" of the output.
TX and RX LEDs
On your board, you will find two labels: TX (transmit) and RX (receive). They
appear in two places on the Arduino UNO board. First, at the digital pins 0 and
1, to indicate the pins responsible for serial communication. Second, the TX and
34
RX led (13). The TX led flashes with different speed while sending the serial
data. The speed of flashing depends on the baud rate used by the board. RX
flashes during the receiving process.
Digital I/O
The Arduino UNO board has 14 digital I/O pins (of which 6 provide PWM
(Pulse Width Modulation) output. These pins can be configured to work as input
digital pins to read logic values (0 or 1) or as digital output pins to drive different
modules like LEDs, relays, etc. The pins labeled “~” can be used to generate
PWM.
AREF
AREF stands for Analog Reference. It is sometimes, used to set an external
reference voltage (between 0 and 5 Volts) as the upper limit for the analog input
pins.
RESULT:
Thus the Arduino Programming was studied and a sample program was executed in IDE
35
Ex No:15 INTERFACING SENSORS WITH ARDUINO
Date
AIM:
To interface various types of sensors with Arduino Board and display the result in the serial
monitor.
APPARATUS REQUIRED:
ULTRASONIC SENSOR
Aim:
Calculate the distance to an object with the help of an ultrasonic sensor and display it on an
LCD.
Ultrasonic Sensors:
The HC-SR04 ultrasonic sensor uses SONAR to determine the distance of an object just like the
bats do. It offers excellent non-contact range detection with high accuracy and stable readings in an easy-
to-use package from 2 cm to 400 cm or 1” to 13 feet. It comes complete with ultrasonic transmitter and
receiver module. The ultrasonic sensor uses the reflection of sound in obtaining the time between the
wave sent and the wave received. It usually sent a wave at the transmission terminal and receives the
reflected waves. The time taken is used together with the normal speed of sound in air (340ms-1) to
determine the distance between the sensor and the obstacle. The Ultrasonic sensor is used here for the
intruder detection.
36
PROGRAM:
int trigPin= 9;
int echoPin= 10;
void setup ()
{
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
Serial.begin(9600);
}
void loop ()
{
Serial.println("loop");
long duration, distance;
digitalWrite(trigPin,HIGH);
delayMicroseconds(1000);
digitalWrite(trigPin, LOW);
duration=pulseIn(echoPin, HIGH);
distance =(duration/2)/29.1;
Serial.print(distance);
Serial.println("CM");
delay(10);
}
OUTPUT:
37
Ex No:16 HUMIDITY SENSOR
Date
Aim:
To study and Interface the Temperature and Humidity with the Arduino
Humidity Sensors:
The Temperature Humidity sensor provides a pre-calibrated digital output. A unique capacitive sensor
element measures relative humidity and the temperature is measured by a negative temperature
coefficient (NTC) thermistor. It has excellent reliability and long term stability
38
PROGRAM:
#include <dht11.h>
#define DHT11PIN 4
dht11 DHT11;
void setup()
{
Serial.begin(9600);
}
void loop()
{
Serial.println();
int chk = DHT11.read(DHT11PIN);
Serial.print("Humidity (%): ");
Serial.println((float)DHT11.humidity, 2);
Serial.print("Temperature (C): ");
Serial.println((float)DHT11.temperature, 2);
delay(2000);
}
OUTPUT:
39
Ex No:17 IR SENSOR
Date
Aim:
IR SENSOR
An IR sensor or infrared sensor is a type of electronic device that emits light in order to detect certain
aspects of its surroundings. The sensor module is ambient light-adaptable, with a pair of infrared
emitting and receiving tubes. At a specific frequency, the transmitting tubes emit infrared. When the
direction of an obstacle is detected (reflective surface), the receiving tube receives the infrared
reflected. After a comparator circuit processing, the green light turns on. And the signal output
interfaces a digital signal (a low-level signal). The sensor’s effective distance range is 2 ~ 30cm. The
sensor’s detection range can be adjusted by adjusting the potentiometer.
40
REG
PROGRAM:
void setup() {
// Initialize Serial communication
Serial.begin(9600);
void loop() {
// Read the IR sensor value
int sensorValue = digitalRead(irSensorPin);
OUTPUT:
41
Ex No:18 BUZZER
Date
Aim:
BUZZER:
Buzzer is the easiest and cost-effective way to add sound to your Arduino projects. Using a buzzer we
can create projects like timer, stopwatch, fire alarm, siren, etc. Most of the active buzzer works at a voltage
range of 3.3V – 5V and generate only one sound frequency. It can only generate a sound of fixedfrequency
when you provide the required voltage to it.
42
PROGRAM:
void setup() {
// Initialize the buzzer pin as an OUTPUT
pinMode(buzzerPin, OUTPUT);
}
void loop() {
// Turn the buzzer on
digitalWrite(buzzerPin, HIGH);
RESULT:
Thus the various sensors are interfaced with Arduino and the outputs were obtained.
43
Ex No:19 COMMUNICATION MODULE-ZIGBEE & ARDUINO
Date
AIM:
APPARATUS REQUIRED:
ZIGBEE MODULE:
Zigbee is a wireless communication protocol targeted for battery powered devices (it has both low power
and low cost). It generally operates in the 2.4GHz range and supports data ranges from 20 to 250 kbits/s.
Digi International developed the XBee modules, a family of wireless communication devices. These
modules support various wireless communication protocols, including Zigbee, Wi-Fi, and cellular, and
they can communicate over UART (Universal Asynchronous Receiver-Transmitter) interfaces. These
modules utilize Zigbee communication, which is a low-power wireless communication protocol
commonly used in home automation, industrial control, and sensor networks. XBee Zigbee modules are
44
capable of forming mesh networks, making them suitable for applications where reliability and long-
range communication are essential.
PROGRAM:
#include <SoftwareSerial.h>
void setup()
{
// Initialize the Hardware Serial interface (usually connected to your
computer)
Serial.begin(9600); // Use the appropriate baud rate
45
if (zigbeeSerial.available()) {
char receivedChar = zigbeeSerial.read();
Serial.print("Received: ");
Serial.println(receivedChar); // Print received data to the Serial Monitor
}
OUTPUT:
h
e
l
l
o
zigbee…
RESULT:
Thus the communication was established between Arduino and Zigbee Module. The data is
transmitted from Zigbee to Arduino.
46
Ex No:20 COMMUNICATE BETWEEN ARDUINO AND BLUETOOTH COMMUNICATION MODULE
Date
AIM:
To communicate with Arduino using Bluetooth model.
APPARATUS REQUIRED:
BLUETOOTH MODULE:
HC-05 is a Bluetooth device used for wireless communication with Bluetooth enabled devices (like
smartphone). It communicates with microcontrollers using serial communication (USART).
There is a simple example of establishing a serial connection between the HC-05 and the Smart Phone
and send/receive message
We will use pins 2and 3 of the Arduino to connect the HC-05 and use the SoftwareSerial library to
communicate with the module. The Hardware serial port on arduino is used to send/receive messages
from the computer to the Arduino.
To pair: Go to the smartphone Bluetooth settings and find nearby available Bluetooth devices. In this list
you will find HC05, select it and then it requires a password which is by default set as 1234 or 0000 enter
the password and devices are now paired.
2) Go to Google Play store and download the “Bluetooth terminal” app from it
3) Open the Bluetooth terminal app and search for the paired device and select it. Now, click on the
connect button that appears on the top right of your screen. Wait for the 5 seconds till you get notification
connected at the bottom and connect button changes in disconnect.
Now you just need to send data from the app which will be transmitted by phones BT through the antenna
and received by the HC05 antenna then HC05 transmit this data from its Tx to RX of the arduino, but
47
data should be a character (integers are also characters in ASCII) not string here the instruction
Serial.read() works.
Serial.print() will transmit data from Arduino Tx to Rx of BT and then BT transmits it to the smartphone
through its antenna and that’s how the two-way communication works.
PROGRAM:
#include<SoftwareSerial.h>
void setup() {
bt.begin(9600); /* Define baud rate for software serial communication */
Serial.begin(9600); /* Define baud rate for serial communication */
}
48
void loop() {
OUTPUT:
RESULT:
Thus the communication was established between Arduino and Bluetooth Module. The data is
transmitted from Bluetooth to Arduino.
49
Ex No:21 RASPBERRY PI PROGRAMMING
Date
AIM:
To study Raspberry Pi programming and installation procedure.
INTRODUCTION
The Raspberry Pi is a low cost, credit-card sized computer that plugs into a computer monitor or
TV, and uses a standard keyboard and mouse. It is a capable little device that enables people of all ages
to explore computing, and to learn how to program in languages like Scratch and Python. It’s capable of
doing everything you’d expect a desktop computer to do, from browsing the internet and playing high-
definition video, to making spreadsheets, word-processing, and playing games.
ARCHITECTURE:
PIN DIAGRAM:
50
COMPONENTS:
51
● MicroSD Card Slot:
○ The Raspberry Pi uses a microSD card as its primary storage, where the operating
system and user data are stored.
● Ethernet Port:
○ Some models include an Ethernet port for a wired network connection, enabling internet
access and local network communication.
● Wi-Fi and Bluetooth (on some models):
○ Integrated wireless connectivity allows the Raspberry Pi to connect to Wi-Fi networks
and Bluetooth-enabled devices.
● Camera and Display Ports:
○ Some models feature ports for connecting the Raspberry Pi Camera Module and official
Display Module, enabling camera and display functionalities.
● Power Port:
○ The power port supplies the Raspberry Pi with the necessary electrical power, often
through a micro USB or USB-C port.
INSTALLATION:
1. Write the bootable Raspberry Pi OS image to the micro SD card or the USB drive directly
using the Raspberry Pi imager application.
2. Download the bootable ISO image of Raspberry Pi OS from the official Raspberry Pi website
and write using the Raspberry Pi imager or Etcher application to the micro SD card or the
USB drive.
Method 1: Flash the Ubuntu image to the micro SD or USB drive directly from the Raspberry Pi Imager
Download the Raspberry Pi Imager application on your Windows PC or mac book. Just follow the on-
screen instructions, and the installation process should be completed in a few minutes. Once the
installation is complete, you can start exploring the features of the Raspberry Pi Imager application.
STEP 1: Download and Install the Raspberry Pi Imager application Raspberry
Pi Imager is a quick and easy way to install Raspberry Pi OS and other operating systems to amicroSD
card or USB drive.
52
STEP 2 : Run the Raspberry Pi Imager application
Upon installation, when you run the Imager application, you will be greeted with this window.
Click on the Choose Storage button on the Imager application. That will show up on the list of connected
micros SD cards or USB storage devices. Select the one you want to install Raspberry Pi OS.
53
STEP 6: Raspberry Pi OS image is being written to the USB storage
STEP 10: The colored window of Raspberry Pi. You will see a colored window like shown here. This
indicates that your Raspberry Pi passed the POST test and is ready to load the operating system.
Upon the completion of the boot process. Raspberry Pi OS will throw a system configuration wizard.
Raspberry Pi OS will ask for several configurations to be set up. You should need to Select the
preferred settings to configure.
The configuration wizard starts from the Language selection all the way it goes to the keyboard,
network, time zone, and login user account settings.
54
STEP 13: Reboot the Raspberry Pi. Upon the completion of the set up process, system will ask to
reboot to complete the process. Click on the Reboot button to continue Reboot.
STEP 14: Raspberry Pi OS is running on the Raspberry Pi. That’s it. Immaterially, upon login, you
will be greeted with this desktop screen.
RESULT:
55
Ex No:22
INTERFACE IR SENSOR WITH RASPBERRY PI
Date
AIM:
To interface IR sensor with Raspberry PI
APPARATUS REQUIRED:
Raspberry Pi
IR Sensor
Connecting cables
IR SENSOR:
An IR sensor or infrared sensor is a type of electronic device that emits light in order to detect certain
aspects of its surroundings. The sensor module is ambient light-adaptable, with a pair of infrared
emitting and receiving tubes. At a specific frequency, the transmitting tubes emit infrared. When the
direction of an obstacle is detected (reflective surface), the receiving tube receives the infrared
reflected. After a comparator circuit processing, the green light turns on. And the signal output
interfaces a digital signal (a low-level signal). The sensor’s effective distance range is 2 ~ 30cm. The
sensor’s detection range can be adjusted by adjusting the potentiometer.
56
PROGRAM:
RESULT:
Thus the IR sensor is interfaced with Raspberry Pi and the obstacle detection was monitored.
57
COMMUNICATE ARDUINO AND RASPBERRY PI
Ex No:23
Date
AIM:
To communicate between Arduino and Raspberry Pi and forward a message from Arduino to
Raspberry Pi.
APPARATUS REQUIRED:
DIAGRAM
58
PROGRAM:
Step 1: Connect the Arduino to the raspberry pi with the help of a USB cable
Step 2: Open thonny and type in the following code to create a serial communication device
with the specified name and port
import serial
ser = serial.Serial('/dev/ttyACM0', 9600)
Step 3: check if the device was created by opening the terminal and typing the following command
ls /dev/tty*
Step 4: Open the arduino ide and upload the following code to the arduino board
void setup()
{
Serial.begin(9600);
}
void loop(){
Serial.println(“Hello Pi”);
delay(2000);
}
Step 5: Now connect the arduino to the raspberry pi again and add the following code to thonny
while 1 :
ser.readline()
Step 6: Now run the code again to observe the data being sent
OUTPUT:
Hello Pi
RESULT:
Thus the communication between Arduino and Raspberry Pi was established and the message was sent
from Arduino to Raspberry Pi using serial communication.
59
Ex No:24
LOG DATA USING CLOUD PLATFORM
Date
AIM:
To create the simplest experiment by using an IoT module with interfaces on the ESP32.
PROCEDURE:
1. Set up the circuit as described in the “Circuit Connection” section.
2. Connect the ESP 32 to your computer using a USB cable.
3. Open the Arduino IDE software on your computer.
4. Write the code for adafruit io interface with Arduino.
5. Verify and upload the code to the ESP 32.
ARDUINO CODE:
#include <ESP8266WiFi.h>
#include "Adafruit_MQTT.h"
#include "Adafruit_MQTT_Client.h"
#include "DHT.h"
#define WLAN_SSID "YOUR_WIFI_SSID"
#define WLAN_PASS "YOUR_WIFI_PASSWORD"
#define AIO_SERVER "io.adafruit.com"
#define AIO_SERVERPORT 1883 // use 8883 for SSL
#define AIO_USERNAME "umaece1982"
#define AIO_KEY "aio_EpaH61HXULkHr4c8izGTucz5Fqoi"
#define DHTPIN D6
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
WiFiClient client;
Adafruit_MQTT_Client mqtt(&client, AIO_SERVER, AIO_SERVERPORT, AIO_USERNAME,
AIO_KEY);
Adafruit_MQTT_Publish temperature = Adafruit_MQTT_Publish(&mqtt, AIO_USERNAME
"feeds/temperature1");
Adafruit_MQTT_Publish humidity = Adafruit_MQTT_Publish(&mqtt, AIO_USERNAME
"feeds/humidity1");
void MQTT_connect();
void setup() {
Serial.begin(115200);
dht.begin();
60
delay(10);
Serial.println("WiFi connected");
Serial.println("IP address: "); Serial.println(WiFi.localIP());
uint32_t x=0;
void loop() {
MQTT_connect();
float h = dht.readHumidity();
float t = dht.readTemperature();
Serial.print(F("\nTemperature: "));
Serial.print(t);
Serial.print(F("\nHumidity: "));
Serial.print(h);
temperature.publish(t);
humidity.publish(h);
delay(60000);
void MQTT_connect() {
int8_t ret;
if (mqtt.connected()) {
return;
}
uint8_t retries = 3;
while ((ret = mqtt.connect()) != 0) { // connect will return 0 for connected
Serial.println(mqtt.connectErrorString(ret));
Serial.println("Retrying MQTT connection in 5 seconds...");
mqtt.disconnect();
delay(5000); // wait 5 seconds
retries--;
if (retries == 0) {
// basically die and wait for WDT to reset me
while (1);
}
}
Serial.println("MQTT Connected!");
}
61
REG
OUTPUTS:
62
RESULT:
The ESP 32 successfully interfaces Adafruit io with Wi-Fi as programed.
63
CONTENT BEYOND
THE SYLLABUS
64
EX.NO.1 ARITHMETIC OPERATION USING 8051
Aim:
Apparatus Required:
PROGRAM:
Addition:
CLR C
MOV B, # 00H
MOV A, #FFH
ADDC A, # FEH
JNC LOOP
INC B
LOOP: MOV DPTR, # 4500H
MOVX @ DPTR, A
INC DPTR
MOV A, B
MOVX @ DPTR, A
HERE: SJMP HERE
65
Subtraction:
CLR C
MOV B# 00H
MOV A #FFH
SUBB A # FEH
JNC LOOP
INC B
LOOP: MOV DPTR # 4500H
MOVX @ DPTR, A
INC DPTR
MOV A, B
MOVX @ DPTR, A
HERE: SJMP HERE
Procedure: -
66
Multiplication
MOV A, # 03H
MOV B, # 02H
MUL AB
MOV DPTR, # 4500H
MOV X @ DPTR, A
INC DPTR
MOV A, B
MOV X @ DPTR, A
HERE: SJMP HERE
Procedure: -
Division:
MOV A, # 65H
MOV B, # 08H
DIV AB
MOV DPTR, # 4500
MOV X @ DPTR, A
INC DPTR
MOV A, B
MOV X @ DPTR, A
HERE: SJMP HERE
67
Procedure: -
Move data 65H immediate to register A.
Move data 08 immediately to register B.
Perform division to both operands A and B.
Store the result.
Then increment the address and then store remainder in increment address.
68
S.NO Operation Address Input Output
4100
1 Addition 4102
4500
4100
2 Subtraction 4102
4500
4100
3 Multiplication 4102
4500
4 4100
Division 4102
4500
Result:
69
EX NO 2 LARGEST NUMBER IN ARRAY OF NUMBER
AIM
To find the largest number of the given number using 8051 micro controller assembly Language
program.
ALGORTHIM: -
Program: -
70
MOVX @ DPTR, A
LOOP1 JC LOOP3
MOV40H, A
SJMP LOOP3
Procedure: -
71
RESULT:
INPUT OUTPUT
Thus the largest of N number is found using the 8051 micro controller.
72
Ex.No: 3
Aim:
To sort the number in ascending and descending order by using 8086 Microprocessor kit.
Apparatus Required:
Procedure:
Result:
The 8086 program to sort the numbers in ascending and descending order was written, entered, executed and
verifi
73
Ex.No 4 DESCENDING ORDER USING 8086 KIT
Aim:
To sort the number in ascending and descending order by using 8086 Microprocessor kit.
Apparatus Required:
Procedure:
Result:
The 8086 program to sort the numbers in descending order was written, entered, executed and verified.
74
Ex.No: 5 ONE’S &TWO’S COMPLEMENT:-USING 8051
Aim:
Apparatus Required:
Result:
Thus One’s &Two’s Complement operations are performed using 8051 micro controller.
75
VIVA VOCE QUESTIONS
76
8051
Register provides a fast way to collect and store data using microcontrollers
and processors. If we want to manipulate data with a controller or processor by
performing tasks like addition, subtraction, and so on, we cannot do that directly in the
memory, in order to perform these tasks we need registers to process and store the data.
Microcontrollers contain several types of registers that can be classified according to
their content or instructions that operate on them.
There are three types of buses. Address bus: This is used to carry the Address
to the memory to fetch either Instruction or Data. Data bus : This is used to carry the
Data from the memory. Control bus : This is used to carry the Control signals like
RD/WR, Select etc
77
6. What is an Opcode?
The part of the instruction that specifies the operation to be performed is
called the Operation code or Op code.
7. What is an Operand?
The data on which the operation is to be performed is called as an Operand.
The language in which the mnemonics (short -hand form of instructions) are
used to write a program is called assembly language. The manufacturers of
microprocessor give the mnemonics.
13. What is the drawback in machine language and assembly language, programs?
The machine language and assembly language programs are machine dependent.
The programs developed using these languages for a particular machine cannot be
directly run on another machine .
Basic Embedded C
78
1. What is Embedded C? How does it differ from standard C?
The volatile keyword in Embedded C is used to inform the compiler that a variable may
be changed unexpectedly by external factors, such as hardware events or interrupts. This
prevents the compiler from optimizing the code in a way that might assume the variable
remains constant, ensuring that the variable is always read from memory instead of being
cached in a register. This is particularly important in embedded systems where memory-
mapped registers and hardware peripherals are often accessed through pointers or global
variables.
datatype array_name[array_size];
int my_array[10];
The static and extern keywords are used to control the visibility and storage duration of
variables and functions in Embedded C.
Void pointers are those pointers that point to a variable of any type. It is a generic pointer as
it is not dependent on any of the inbuilt or user-defined data types while referencing. During
79
dereferencing of the pointer, we require the correct data type to which the data needs to be
dereferenced.
2. Can you explain the difference between Arduino and Raspberry Pi, and when you would prefer one
over the other in a project?
For Raspberry Pi when needing complex software, internet connectivity, or multimedia capabilities.
8. What are the Key Differences Between ZigBee and Other Wireless Protocols like Wi-Fi and Bluetooth?
Primary Use Cases:
ZigBee: Low-power, low-data-rate applications like home automation and sensor networks.
Wi-Fi: High-speed internet access and data transfer.
Bluetooth: Short-range communication between devices like smartphones and headphones.
Power Consumption:
Network Topology:
9. What is Bluetooth?
Bluetooth is a wireless technology standard used for exchanging data over short distances from fixed
and mobile devices, creating personal area networks with high levels of security.
81
2.4 GHz frequency band and can connect up to eight devices simultaneously.
82