0% found this document useful (0 votes)
143 views189 pages

Microprocessor Theory and Interfacing LAB MANUAL Goup

This document appears to be the preface or introduction section of a laboratory manual for a Microprocessor Theory and Interfacing lab course. It lists the contributors who prepared and approved the manual, including faculty members and a lab engineer. It provides general lab instructions that students should follow which focus on safety, maintaining records of observations and results, and ensuring circuits are correctly set up and disconnected. The document establishes guidelines and procedures to structure the hands-on learning experience in the lab.

Uploaded by

80 14Aqib Saeed
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)
143 views189 pages

Microprocessor Theory and Interfacing LAB MANUAL Goup

This document appears to be the preface or introduction section of a laboratory manual for a Microprocessor Theory and Interfacing lab course. It lists the contributors who prepared and approved the manual, including faculty members and a lab engineer. It provides general lab instructions that students should follow which focus on safety, maintaining records of observations and results, and ensuring circuits are correctly set up and disconnected. The document establishes guidelines and procedures to structure the hands-on learning experience in the lab.

Uploaded by

80 14Aqib Saeed
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
You are on page 1/ 189

Government College University, Faisalabad

Department of Electrical Engineering & Technology,

Microprocessor Theory And Interfacing


Lab Manual
Prepared & Edited by:

Dr. Ali Raza (Assistant Professor)


Mubashar Ahmad (Lab Engineer)

Verified by:
Engr. Dr. Muhammad Farhan
(Assistant Professor)

Approved by:

Dr. Abdul Rauf Bhatti


Associate Professor, Chairman
Electrical Engineering & Technology Department

Microprocessor Theory And Interfacing Lab Manual i


Table of Lab Experiment’s
Experiment # 1: Introduction to the 8086 microprocessor & mda-8086 trainer.....................1

Experiment # 2: Serial communication interface between mda-8086 trainer and pc..........32

Experiment # 3: Interfacing of led’s using 8255a interface with mda-8086 trainer..............42

Experiment # 4: Interfacing of 7-segment using 8255a interface with mda-8086 trainer....48

Experiment # 5: Introduction of Arduino.................................................................................56

Microprocessor Theory And Interfacing Lab Manual ii


PREFACE

The laboratory of each and every subject taught in the degree of bachelor’s in
electrical engineering & Technology is of very much importance in every University.
Fully equipped laboratory meeting the industrial demands under the supervision of
qualified, talented, and practically motivated lab assistants and lab engineers is also a basic
criterion of the National Technology Council. This Manual has been formulated
considering all these above mentioned points.

This manual is according to the equipment supplied by the Mechanical Engineering


Services, Faisalabad and meets the requirements of all the course of Electrical Workshop
as per the curriculum of G. C. University Faisalabad.

With Regards
Mubashar Ahmad
Lab Engineer

Microprocessor Theory And Interfacing Lab Manual iii


General Lab Instructions
 Each student group consists of a maximum of 2-4 students. Each group member is responsible
in submitting lab report upon completion of each experiment on their practical Notebook.
 Students are to wear proper attire i.e shoe or sandal instead of slipper. Excessive jewelleries
are not advisable as they might cause electrical shock.
 A permanent record in ink of observations as well as results should be maintained by each
student and enclosed with the report.
 The recorded data and observations from the lab manual need to be approved and
signed by the lab instructor upon completion of each experiment.
 Before beginning connecting up, it is essential to check that all sources of supply at the bench are
switched off.
 Start connecting up the experiment circuit by wiring up the main circuit path, then adds the
parallel branches as indicated in the circuit diagram.
 After the circuit has been connected correctly, remove all unused leads from the experiment
area, set the voltage supplies at the minimum value, and check the meters are set for the
intended mode of operation.
 The students may ask the lab instructor to check the correctness of their circuit before
switching on.
 When the experiment has been satisfactory completed and the results approved by the
instructor, the students may disconnect the circuit and return the components and instruments
to the locker tidily. Chairs are to be slid in properly.

Microprocessor Theory And Interfacing Lab Manual iv


Psychomotor Domain Rubrics
Levels
PLO
no Criteria Beginning (1) Developing (2) Accomplished (3) Exemplary (4)
Apply With instructor/ supervisor’s With instructor/ supervisor’s Student is able to apply all
Student is unable to apply
Procedural guidance, student is able to guidance, student is able to procedural knowledge to
described procedure to perform
1 Knowledge to apply some of the described apply all described independently perform
activity despite instructor/
perform an procedure to partially perform procedure to fully perform activity without instructor/
activity supervisor’s guidance. activity. activity. supervisor’s guidance.
Student is able to
Student is unable to design With instructor/ supervisor’s
Design systems, With instructor/ supervisor’s independently design
systems, components and/or guidance, student is able to
components guidance, student is able to systems, components and/or
processes to meet fully design systems,
3 and/or processes partially design systems, processes to meet
specifications despite components and/or
to meet components and/or processes specifications without
instructor/ supervisor’s processes to meet
specifications to meet specifications. instructor/ supervisor’s
guidance. specifications.
guidance.
Student is able to
Data Analysis Student is unable to analyze/ With instructor/ supervisor’s With instructor/ supervisor’s
independently
and interpret obtained results guidance, student is able to guidance, student is able to
4 analyze/interpret obtained
interpretation of despite instructor/ supervisor’s partially analyze/interpret fully analyze/interpret
results without instructor/
obtained results guidance. obtained results. obtained results.
supervisor’s guidance.
Operational Student has shown little to no
With instructor/ supervisor’s With instructor/ supervisor’s Student can handle/use all
Skills for ability to handle/use
guidance, student can guidance, student can equipment/software and
Hardware/Softw equipment/software and
5 handle/use some of the handle/use all involved components without
are equipment involved components despite
equipment/ software and equipment/software and instructor/ supervisor’s
and involved instructor/ supervisor’s
involved components. involved components. guidance.
components guidance.

Student has shown little to no


With instructor/ supervisor’s Student has followed all
Follow personal regard for personal and With instructor/ supervisor’s
guidance, student followed safety rules and protocols
6 and equipment equipment safety regulations guidance, student followed
some of the personal and without instructor/
Safety Rules despite instructor/ supervisor’s all safety rules.
equipment safety regulations supervisor’s guidance.
guidance.

Microprocessor Theory And Interfacing Lab Manual v


Experiment # 1: Introduction to the 8086
microprocessor & mda-8086 trainer

OBJECTIVE
To have the idea of the 8086 architecture.
To have detailed information about the MDA-8086 Microprocessor Trainer

EQUIPMENT
PC having Intel microprocessor, MDA-8086 kit.
MDA-Win8086
Power Cords
Communication Cables
Data Sheet
THEORY
A microprocessor is a controlling unit of a micro-computer, fabricated on a small chip capable of
performing Arithmetic Logical Unit (ALU) operations and communicating with the other
devices connected to it. Microprocessor consists of an ALU, register array, and a control unit.
ALU performs arithmetical and logical operations on the data received from the memory or an
input device. Register array consists of registers identified by letters like B, C, D, E, H, L and
accumulator. The control unit controls the flow of data and instructions within the computer.

The general microcontroller consists of the processor, the memory (RAM, ROM, EPROM),
Serial ports, peripherals (timers, counters), etc. A typical microcontroller includes a processor,
memory, and input/output (I/O) peripherals on a single chip.

Microprocessor Theory And Interfacing Lab Manual 1


808
6 is
an
enh
anc
ed
vers
ion
of
808
5 that has been developed by Intel in 1976.
It is a 16 bit Microprocessor. It has a powerful instruction set and it is capable to providing
multiplication and division operations directly. It has 20 address lines and 16 data lines. So it can
access up to 1 MB of memory. It supports two modes of operation: first is maximum mode and
second is minimum mode. Minimum mode is applicable for system that have a single processor
and maximum mode is used for the multiprocessor system.
8086 provides an additional features that it has an instruction queue capable to store six
instruction bytes from the memory. The next instruction is fetched while the present instruction

Microprocessor Theory And Interfacing Lab Manual 2


is being executed. So it makes the processor fast.

Pin Diagram:
The introduction to the pins of the 8086 are as follows:
8086 was the first 16-bit microprocessor available in 40-pin DIP (Dual Inline Package) chip. It
consists of different input, output, control, clock and communication pins.
The detail of all the pins is present in the data sheet of the 8086.

AD0-AD15 (Bidirectional) Address/Data bus


Low order address bus; these are multiplexed with data.
When AD lines are used to transmit memory address the symbol A is used instead of AD, for
example A0-A15. When data are transmitted over AD lines the symbol D is used in place of AD,
for example D0-D7, D8-D15 or D0-D15. A16/S3, A17/S4, A18/S5, A19/S6 High order
address bus. These are multiplexed with status signals
BHE (Active Low)/S7 (Output) Bus High Enable/Status
It is used to enable data onto the most significant half of data bus, D8-D15. 8-bit device
connected to upper half of the data bus use BHE (Active Low) signal. It is multiplexed with

Microprocessor Theory And Interfacing Lab Manual 3


status signal S7.
MN/ MX MINIMUM / MAXIMUM
This pin signal indicates what mode the processor is to operate in. The 8086 microprocessor can
work in two modes of operations: Minimum mode and Maximum mode. In the minimum mode
of operation, the microprocessor do not associate with any co-processors and cannot be used for
multiprocessor systems. In the maximum mode the 8086 can work in multi-processor or co-
processor configuration.
Minimum or maximum mode operations are decided by the pin MN/ MX(Active low). When
this pin is high 8086 operates in minimum mode otherwise it operates in Maximum mode. Pins
24 -31
For minimum mode operation, the MN/ (MX) ̅ is tied to VCC (logic high)
8086 itself generates all the bus control signals
RD (Read) (Active Low)
The signal is used for read operation. It is an output signal. It is active when low.
TEST (TEST) ̅ input is tested by the ‘WAIT’ instruction. 8086 will enter a wait state after
execution of the WAIT instruction and will resume execution only when the (TEST) ̅ is made low
by an active hardware. This is used to synchronize an external activity to the processor internal
operation.
READY This is the acknowledgement from the slow device or memory that they have
completed the data transfer. The signal made available by the devices is synchronized by the
8284A clock generator to provide ready input to the 8086. The signal is active high.
RESET (Input) Causes the processor to immediately terminate its present activity. The signal
must be active HIGH for at least four clock cycles.
CLK The clock input provides the basic timing for processor operation and bus control activity.
It’s an asymmetric square wave with 33% duty cycle.
INTR Interrupt Request This is a triggered input. This is sampled during the last clock cycles of
each instruction to determine the availability of the request. If any interrupt request is pending,
the processor enters the interrupt acknowledge cycle. This signal is active high and internally
synchronized.
DT/R ̅ (Data Transmit/ Receive) Output signal from the processor to control the direction of data
flow through the data transceivers
(DEN) ̅ (Data Enable) Output signal from the processor used as output enable for the
transceivers
ALE (Address Latch Enable) Used to demultiplex the address and data lines using external
latches
M/(IO) ̅ Used to differentiate memory access and I/O access. For memory reference instructions, it
is high. For IN and OUT instructions, it is low.
(WR) ̅ Write control signal; asserted low whenever processor writes data to memory or I/O port
(INTA) ̅ (Interrupt Acknowledge) When the interrupt request is accepted by the processor, the
output is low on this line.
HOLD Input signal to the processor form the bus masters as a request to grant the control of the
bus.
Usually used by the DMA controller to get the control of the bus.

Microprocessor Theory And Interfacing Lab Manual 4


HLDA (Hold Acknowledge) Acknowledge signal by the processor to the bus master requesting
the control of the bus through HOLD. The acknowledge is asserted high, when the processor
accepts HOLD.

̅𝑺̅𝟎̅, ̅𝑺̅𝟏̅, ̅𝑺̅𝟐̅ Status signals; used by the 8086 bus controller to generate bus timing and
control signals. These are decoded as shown
̅𝑸̅̅𝑺̅̅𝟎̅, ̅𝑸̅̅𝑺̅̅𝟏̅ (Queue Status) the processor provides the status of queue in these lines. The
queue status can be used by external device to track the internal status of the queue in 8086. The
output on QS0 and QS1 can be interpreted as shown in the table.
̅𝐑̅̅𝐐̅/̅𝐆̅̅𝐓̅𝟎̅, ̅𝐑̅̅𝐐̅/𝐆̅̅̅𝐓̅𝟏̅ (Bus Request/ Bus Grant)) these requests are used by other
local bus masters to force the processor to release the local bus at the end of the processor’s
current bus cycle.
These pins are bidirectional. The request on(GT_0 ) ̅ will have higher priority than(GT_1 ) ̅.
̅𝐋̅𝐎̅̅̅𝐂̅̅𝐊̅ An output signal activated by the LOCK prefix instruction. Remains active until the
completion of the instruction prefixed by LOCK. The 8086 output low on the (LOCK) ̅ pin while
executing an instruction prefixed by LOCK to prevent other bus masters from gaining control of
the system bus.
Features of 8086:
The most prominent features of 8086 microprocessor are as follows:
1. It has an instruction queue, which is capable of storing six instruction bytes
from the memory resulting in faster processing.

2. It was the first 16-bit processor having 16-bit ALU, 16-bit registers, internal data
bus, and 16-bit external data bus resulting in faster processing.
3. It is available in 3 versions based on the frequency of operation −

Microprocessor Theory And Interfacing Lab Manual 5


8086 → 5MHz
8086-2 → 8MHz
8086-1 → 10 MHz
4. It uses two stages of pipelining, i.e., Fetch Stage and Execute Stage, which
improves performance.
5. Fetch stage can prefetch up to 6 bytes of instructions and stores them in the queue
6. Execute stage executes these instructions.
7. It has 256 vectored interrupts.
8. It consists of 29,000 transistors.

Architecture Block Diagram:


The block diagram of the architecture of the 8086 is as follows:

Microprocessor Theory And Interfacing Lab Manual 6


Execution Unit (EU)
EU executes instructions that have already been fetched by the BIU. BIU and EU functions
separately. EU executes instructions from the instruction system byte queue. Decodes
instructions fetched by the BIU Generate control signals, Executes instructions.
Bus Interface Unit (BIU)
BIU fetches instructions, reads data from memory and I/O ports, writes data to memory and I/ O
ports. The BIU performs all bus operations such as instruction fetching, reading and writing
operands for memory and calculating the addresses of the memory operands. The instruction
bytes are transferred to the instruction queue.
BIU CONTAINS
Instruction queue,
Segment registers,
Instruction pointer,
Address adder.
EU CONTAINS
Control circuitry,
Instruction decoder,
ALU,
Pointer and Index register,
Flag register.

Microprocessor Theory And Interfacing Lab Manual 7


Functional Units:
8086 Microprocessor is divided into two functional units, i.e., EU (Execution Unit) and BIU
(Bus Interface Unit).
1. EU (Execution Unit)
Execution unit gives instructions to BIU stating from where to fetch the data and then decode
and execute those instructions. Its function is to control operations on data using the instruction
decoder & ALU. EU has no direct connection with system buses as shown in the above figure, it
performs operations over data through BIU.
Let us now discuss the functional parts of 8086 microprocessors.
ALU
It handles all arithmetic and logical operations, like +, −, ×, /, OR, AND, NOT operations.
Flag Register
It is a 16-bit register that behaves like a flip-flop, i.e., it changes its status according to the result
stored in the accumulator. It has 9 flags, and they are divided into 2 groups − Conditional Flags
and Control Flags.
Conditional Flags
It represents the result of the last arithmetic or logical instruction executed. Following is the list
of conditional flags −
Carry flag − This flag indicates an overflow condition for arithmetic operations.
Auxiliary flag − When an operation is performed at ALU, it results in a carry/barrow from lower
nibble (i.e. D0 – D3) to upper nibble (i.e. D4 – D7), then this flag is set, i.e. carry given by D3 bit
to D4 is AF flag. The processor uses this flag to perform binary to BCD conversion.
Parity flag − This flag is used to indicate the parity of the result, i.e. when the lower order 8-bits
of the result contains even number of 1’s, then the Parity Flag is set. For odd number of 1’s, the

Microprocessor Theory And Interfacing Lab Manual 8


Parity Flag is reset.
Zero flag − This flag is set to 1 when the result of arithmetic or logical operation is zero else it is
set to 0.
Sign flag − This flag holds the sign of the result, i.e. when the result of the operation is negative,
then the sign flag is set to 1 else set to 0.
Overflow flag − This flag represents the result when the system capacity is exceeded.
Control Flags
Control flags controls the operations of the execution unit. Following is the list of control flags
Trap flag − It is used for single step control and allows the user to execute one instruction at a
time for debugging. If it is set, then the program can be run in a single step mode.
Interrupt flag − It is an interrupt enable/disable flag, i.e. used to allow/prohibit the interruption of
a program. It is set to 1 for interrupt enabled condition and set to 0 for interrupt disabled
condition.
Direction flag − It is used in string operation. As the name suggests when it is set then string
bytes are accessed from the higher memory address to the lower memory address and vice-a-
versa.
General purpose register
There are 8 general purpose registers, i.e., AH, AL, BH, BL, CH, CL, DH, and DL. These
registers can be used individually to store 8-bit data and can be used in pairs to store 16bit data.
The valid register pairs are AH and AL, BH and BL, CH and CL, and DH and DL. It is referred
to the AX, BX, CX, and DX respectively.
AX register − It is also known as accumulator register. It is used to store operands for arithmetic
operations.
BX register − It is used as a base register. It is used to store the starting base address of the
memory area within the data segment.
CX register − It is referred to as counter. It is used in loop instruction to store the loop counter.
DX register − This register is used to hold I/O port address for I/O instruction.
Stack pointers register
It is a 16-bit register, which holds the address from the start of the segment to the memory

location, where a word was most recently stored on the stack.

2. BIU (Bus Interface Unit)

Microprocessor Theory And Interfacing Lab Manual 9


BIU takes care of all data and addresses transfers on the buses for the EU like sending addresses,
fetching instructions from the memory, reading data from the ports and the memory as well as
writing data to the ports and the memory. EU has no direction connection with System Buses, so
this is possible with the BIU. EU and BIU are connected with the Internal Bus.
It has the following functional parts −
Instruction queue − BIU contains the instruction queue. BIU gets up to 6 bytes of next
instructions and stores them in the instruction queue. When EU executes instructions and is
ready for its next instruction, then it simply reads the instruction from this instruction queue
resulting in increased execution speed.
Fetching the next instruction while the current instruction executes is called pipelining.
Segment register − BIU has 4 segment buses, i.e. CS, DS, SS& ES. It holds the addresses of
instructions and data in memory, which are used by the processor to access memory locations.
It
also contains 1 pointer register IP, which holds the address of the next instruction to executed by
the EU.
CS − It stands for Code Segment. It is used for addressing a memory location in the code
segment of the memory, where the executable program is stored.
DS − It stands for Data Segment. It consists of data used by the program and is accessed in the
data segment by an offset address or the content of other register that holds the offset address.
SS − It stands for Stack Segment. It handles memory to store data and addresses during
execution.
ES − It stands for Extra Segment. ES is additional data segment, which is used by the string to
hold the extra destination data.
Instruction pointer − It is a 16-bit register used to hold the address of the next instruction to be
executed.

Pointer and Index Registers


Used to keep offset addresses.
Used in various forms of memory addressing.
In the case of SP and BP the default reference to form a physical address is the Stack Segment
(SS-will be discussed under the BIU)
The index registers (SI & DI) and the BX generally default to the Data segment register (DS).
SP: Stack pointer
– Used with SS to access the stack segment
BP: Base Pointer
– Primarily used to access data on the stack
– Can be used to access data in other segments
SI: Source Index register
– is required for some string operations
– When string operations are performed, the SI register points to memory
locations in the data segment which is addressed by the DS register. Thus, SI is associated
with the DS in string operations.
DI: Destination Index register
– is also required for some string operations.
– When string operations are performed, the DI register points to memory
locations in the data segment which is addressed by the ES register. Thus, DI is associated

Microprocessor Theory And Interfacing Lab Manual 10


with the ES in string operations. The SI and the DI registers may also be used to access data
stored in arrays
EXECUTION UNIT – Flag Register
A flag is a flip flop which indicates some conditions produced by the execution of
an instruction or controls certain operations of the EU.
In 8086 The EU contains
16 bit flag register, 9 of the 16 are active flags and remaining 7 are undefined.
6 flags indicates some conditions- status flags
3 flags –control Flags

Flag Purpose
Carry (CF) Holds the carry after addition or the borrow after subtraction.
Also indicates some error conditions, as dictated by some
programs and procedures .
Parity (PF) PF=0;odd parity, PF=1;even parity.
Auxiliary (AF) Holds the carry (half – carry) after addition or borrow after
subtraction between bit positions 3 and 4 of the result
(for example, in BCD addition or subtraction.)
Zero (ZF) Shows the result of the arithmetic or logic operation.
Z=1; result is zero. Z=0; The result is 0
Sign (SF) Holds the sign of the result after an arithmetic/logic instruction
execution. S=1; negative, S=0
Trap (TF) A control flag. Enables the trapping through an on-chip debugging
feature
Interrupt (IF) A control flag. Controls the operation of the INTR (interrupt
request) I=0; INTR pin disabled. I=1; INTR pin enabled.
Direction (DF) A control flag. It selects either the increment or decrement mode for
DI and /or SI registers during the string instructions.
Overflow (OF) Overflow occurs when signed numbers are added or subtracted. An
overflow indicates the result has exceeded
the capacity of the Machine

Microprocessor Theory And Interfacing Lab Manual 11


RISC (Reduced Instruction Set Computer)
The idea is that the microcontroller recognizes and executes only basic operations (addition,
subtraction, copying etc.). All other more complicated operations are performed by combining
these (for example, multiplication is performed by performing successive addition). This makes
this language easy to learn.
CISC (Complex Instruction Set Computer)
Microcontrollers designed to recognize more than 200 different instructions can do really much
and are very fast. However, one should know how to take all that such a rich language offers,
which is not easy at all.

THE QUEUE (Q)


The BIU uses a mechanism known as an instruction stream queue to implement a
pipeline architecture.
This queue permits pre-fetch of up to 6 bytes of instruction code. Whenever the queue of
the BIU is not full, it has room for at least two more bytes and at the same time the EU is not
requesting it to read or write operands from memory, the BIU is free to look ahead in the
program by pre-fetching the next sequential instruction.

Microprocessor Theory And Interfacing Lab Manual 12


The size of each segment is 64 KB
A segment may be located anywhere in the memory
Each of these segments can be used for a specific function.
Code segment is used for storing the instructions.
The stack segment is used as a stack, and it is used to store the return addresses.
The data and extra segments are used for storing data byte.
The 4 segments are Code, Data, Extra and Stack segments.
A Segment is a 64kbyte block of memory.
The 16 bit contents of the segment registers in the BIU actually point to the starting location of a
particular segment.
Segments may be overlapped or non-overlapped
In 8086/88 the processors have 4 segments registers
Code Segment register (CS), Data Segment register (DS), Extra Segment register (ES)
and Stack Segment (SS) register.
All are 16 bit registers.
Each of the Segment registers store the upper 16 bit address of the starting address of the
corresponding segments.

Microprocessor Theory And Interfacing Lab Manual 13


Segment and Address register combination
CS:IP
SS:SP SS:BP
DS:BXDS:SI
DS:DI (for other than string operations)
ES:DI (for string operations)
Segment address defines the beginning address of any 64K-byte memory segment
Offset address selects any location within the 64K byte memory segment

Microprocessor Theory And Interfacing Lab Manual 14


Microprocessor Theory And Interfacing Lab Manual 15
PIPELINING
Pipelining meaning, a task is often begun before the previous task has ended. This is
known as pipelining
Pipeline improves the efficiency.
ADDRESSING MOD
Immediate Addressing Mode
Direct Addressing Mode
Register (Direct) Addressing Mode

Microprocessor Theory And Interfacing Lab Manual 16


Register Indirect Addressing Mode
Base-Plus-Index Addressing Mode
Register Relative Addressing Mode
Base-Relative-Plus-Index Addressing Mode
INSTRUCTION SET
8086 supports 6 types of instructions.
Data Transfer Instructions
Arithmetic Instructions
Logical Instructions
String manipulation Instructions
Process Control Instructions
Control Transfer Instructions
Data Transfer Instructions:
Instructions that are used to transfer data/ address in to registers, memory locations and I/O ports.
MOV, XCHG, PUSH, POP, IN, OUT …
Arithmetic Instructions:
ADD, ADC, SUB, SBB, INC, DEC, MUL, DIV, CMP…
Logical Instructions:
AND, OR, XOR, TEST, SHR, SHL, RCR, RCL …
String manipulation Instructions/ Process Control Instructions
Mnemonics Explanation

STC Set CF  1
CLC Clear CF  0
CMC Complement carry CF  CF/
STD Set direction flag DF  1
CLD Clear direction flag DF  0
STI Set interrupt enable flag IF  1
CLI Clear interrupt enable flag IF  0
NOP No operation
HLT Halt after interrupt is set
WAIT Wait for TEST pin active
ESC opcode mem/ reg Used to pass instruction to a coprocessor which
shares the address and data bus with the 8086
LOCK Lock bus during next instruction
Control Transfer Instructions

Microprocessor Theory And Interfacing Lab Manual 17


Mnemonics Explanation

JC disp8 Jump if CF = 1

JNC disp8 Jump if CF = 0

JP disp8 Jump if PF = 1

JNP disp8 Jump if PF = 0

JO disp8 Jump if OF = 1

JNO disp8 Jump if OF = 0

JS disp8 Jump if SF = 1

JNS disp8 Jump if SF = 0

JZ disp8 Jump if result is zero, i.e, Z = 1

JNZ disp8 Jump if result is not zero, i.e, Z =


1

8086 UNCONDITIONAL TRANSFERS


Mnemonics Explanation

CALL reg/ mem/ disp16 Call subroutine

RET Return from subroutine

JMP reg/ mem/ disp8/ disp16 Unconditional jump

Mnemonics Explanation
CALL reg/ mem/ disp16 Call subroutine
RET Return from subroutine
JMP reg/ mem/ disp8/ disp16 Unconditional jump

PART –II THEORY


MDA-8086 has high performance 64K-byte monitor program. It is designed for easy function.
After power is on, the monitor begins to work. In addition to all the key function the monitor has
a memory checking routine.

Microprocessor Theory And Interfacing Lab Manual 18


This a lab interfacing microcontroller module, which have different modules that can be
programmed and can be controlled according to our requirement. It has different Inputs, Outputs,
Memory, and display and the Communication ports.

MDA-8086 Features.

1. Program debugging function by PC.


2. Software : TURBO-C 2.0 or later, Support Startup Code
3. Program download and trace function
4. Display the register contents
5. Memory contents modification and dump function
6. Various Command function
7. Included stepper motor interface circuit
8. DOT MATRIX unit
9. LCD display unit
10. D/A and A/D converter experiment
11. Sound experiment with Speaker
12. Interrupt experiments
13. Thermistor Sensor
14. Bar LED unit
15. Keyboard experiment
16. External interface connector
17. Display the current BUS status on LED
18. +5V, +12V, -12V S.M.P.S (Free Voltage) Power.
The function of IC's at Figure 1.
① CPU(Central processing unit) :
Using Intel 8086, Using 14.7456㎒.

Microprocessor Theory And Interfacing Lab Manual 19


② ROM(Read Only Memory) :
It has program to control user's key input.
LCD display, user's program.
64K Byte, it has data communication program.
Range of ROM Address is F0000H~FFFFFH.
③ SRAM(Static Random Access Memory) :
Input user's program & data.
Address of memory is 00000H~0FFFFH, totally 64K Byte.
④ DISPLAY :
Text LCD Module, 16(Characters)×2(Lines)
⑤ KEYBOARD :
It is used to input machine language.
There are 16 hexadecimal keys and 8 function keys.
⑥ SPEAKER :
Sound test.
⑦ RS-232C
Serial communication with IBM compatible PC.
:
⑧ DOT MATRIX LED :
To understand & test the dot matrix structure and principle of display.
It is interfaced to 8255A (PPI).
⑨ A/D CONVERTER :
ADC0804 to convert the analog signal to digital signal.
⑩ D/A CONVERTER :
DAC0800 (8-bits D/A converter) to convert the digital signal to the analog signal
To control the level meter.
⑪ STEPPING MOTOR INTERFACE :
Stepping motor driver circuit is designed.
⑫ POWER :
AC 110~220V,
DC +5V 3A, +12V 1A, -12V 0.5A SMPS.

Microprocessor Theory And Interfacing Lab Manual 20


Microprocessor Theory And Interfacing Lab Manual 21
Figure 1

Microprocessor Theory And Interfacing Lab Manual 22


MDA-Win8086 has high performance 64K-byte monitor program. It is designed for easy
function. After power is on, the monitor program begins to work. In addition to all the key
function the monitor has a memory checking routine. The following is a simple description of the
key functions.

Microprocessor Theory And Interfacing Lab Manual 23


Microprocessor Theory And Interfacing Lab Manual 24
Microprocessor Theory And Interfacing Lab Manual 25
Microprocessor Theory And Interfacing Lab Manual 26
Microprocessor Theory And Interfacing Lab Manual 27
Microprocessor Theory And Interfacing Lab Manual 28
Microprocessor Theory And Interfacing Lab Manual 29
Microprocessor Theory And Interfacing Lab Manual 30
CONCLUSION

 In this experiment, we understand the idea of mda-8086 and learned about all
components which are embedded on board,
 And also acknowledge the working of hardware like keypad, LEDs, etc.

Activity Name  Introduction to the 8086 microprocessor & mda-8086 trainer


Group No.  07
Student Roll No.  8034 8035 8036 8037
C P Domain +
No. L Taxonomy Criteria Awarded Score (out of 4 for each cell)
L O
O
Conduct experiments in
laboratory in order to interpret
1 A2 experimental data and displays
its conformance with analyzed
results of circuits.

Total

Microprocessor Theory And Interfacing Lab Manual 31


Experiment # 2: Serial communication interface
between mda-8086 trainer and pc.

OBJECTIVE
To get familiar with the serial communication between mda-8086 trainer and pc.
EQUIPMENT
PC having Intel microprocessor, MDA-8086 kit.

THEORY:-
Serial Monitor:-
Serial monitor is the basic monitor program to do data communicate between MDA-Win8086
and your computer.
How to setup the serial monitor
Adjust the P1 switch as following figure.

How to connect MDA‐Win8086 to your PC

① Connect the MDA-Win8086 Kit to a spare serial port on your PC.

Microprocessor Theory And Interfacing Lab Manual 32


MDA‐WinIDE8086 Installation
➀ Insert the CD in the CD-ROM driver, and double click the
file "SETUP.EXE".
➁ The installation begins.

Microprocessor Theory And Interfacing Lab Manual 33


Launching MDA-WinIDE8086
Click the Start button in the task bar, then click All Programs and MIDAS ENG. Then click the
MDA-WinIDE8086 program icon.

The MDA-WinIDE8086 window will be displayed:-

Microprocessor Theory And Interfacing Lab Manual 34


About MDA-WinIDE8086

Menu bar

Microprocessor Theory And Interfacing Lab Manual 35


Gives access to the MDA-WinIDE8086 menu.

Microprocessor Theory And Interfacing Lab Manual 36


Tool bar
The tool bar provides button s for the most useful commands on the MDA-WinIDE8086 menus.

Microprocessor Theory And Interfacing Lab Manual 37


Editor window
Source file is displayed in the editor window. The MDA-WinIDE8086 editor automatically
recognizes the syntax of C program and Assemble program.

Terminal window
Terminal window is that you can use to connect the MDA-Win8086 kit.

Microprocessor Theory And Interfacing Lab Manual 38


Assembling and compiling the source

Troubleshooting
The output window lists tool information during the code generation. You may check on error
messages to correct syntax errors in your program.

Microprocessor Theory And Interfacing Lab Manual 39


Port setting
⑴ After connect the MDA-Win8086 kit to a spare serial port on your PC, press RESET KEY,
then "8086>" prompt will be displayed.

Select the serial port to connected to your PC. (ie. COM1, COM2, COM3 or COM4 ) BPS :
9600, Parity : None, Stop bits : 1
Press MDA-Win8086 RESET KEY again then "8086>" prompt will be displayed.

Download and execute the source file


1. Download
Click button or select Program Write from the Work menu. You can also type 'L' and
"Enter" key on Terminal window, then press "Page Up" button from your keyboard.
Execute
⑴ Run

Microprocessor Theory And Interfacing Lab Manual 40


Click button or select "Run" from the Run menu. You can also type 'G' and "Enter" key on
Terminal window. The Run command in the work menu starts execution of the program. The
Program will be executed until it is stopped by pressing RESET KEY.
⑵ Trace

Click button or select "Trace" from the Run menu. You can also type 'T' and "Enter" key

on Terminal window. The Trace command in the work menu executes one instruction.

CONCLUSION:-
 In this experiment, we managed to create a communication between pc and mda-
8086 trainer.
 And learned about program setup on pc, work tabs, port setting, compiling and
execution of Instruction.

Activity Name 
Serial communication interface between mda-8086 trainer
and pc.
Group No.  07
Student Roll No.  8034 8035 8036 8037
C PL Domain +
No. O Taxonomy Criteria Awarded Score (out of 4 for each cell)
L
O
Conduct experiments in
laboratory in order to interpret
1 A2 experimental data and displays
its conformance with analyzed
results of circuits.
-
- - - - -
Total

Microprocessor Theory And Interfacing Lab Manual 41


Experiment # 3: Interfacing of led’s using 8255a
interface with mda-8086 trainer
OBJECTIVE
 To get familiar with the LED display and its interfacing with 8086 microprocessor using
8255A.
EQUIPMENT
 PC having Intel microprocessor, MDA-8086 kit.

THEORY
Peripheral Interfacing is considered to be a main part of Microprocessor, as it is the only way to
interact with the external world. The interfacing happens with the ports of the Microprocessor.

PROGRAMMABLE PERIPHERAL INTERFACE - INTEL 8255

Pins, Signals and internal block diagram of 8255:

 It has 40 pins and requires a single +5V supply.

 The INTEL 8255 is a device used to parallel data transfer between processor and
slow peripheral devices like ADC, DAC, keyboard, 7-segment display, LCD, etc.
 The 8255 has three ports: Port-A, Port-B and Port-C.

Microprocessor Theory And Interfacing Lab Manual 42


 RD (low): This control signal enables the read operation. When this signal is
low, the microprocessor reads data from a selected I/O port of the 8255A.
 WR (low): This control signal enables the write operation. When this signal goes
low, the microprocessor writes into a selected I/O port or the control register.
 RESET: This is an active high signal. It clears the control register and set all ports in the
input mode.
 CS (low), A0 and A1: These are device select signals. They are,

Microprocessor Theory And Interfacing Lab Manual 43


CONNECTION DIAGRAM

Microprocessor Theory And Interfacing Lab Manual 44


PROCEDURE:-
1. Connect MDA 8085 Microprocessor Trainor with PC with Serial Port.
2. ON the MDA 8085 Microprocessor Trainor and Select Serial Monitor Mode with mode
selection switch P1 to PC
3. Run the MDA 8085 Microprocessor program.
4. Press RES button to check the connective between PC and Trainor.
5. Write the Program for LEC controlling.
6. Open the Program File.
7. Start Compiling of target application with Compile and Link button.
8. Download / load the program and then run the program.
9. Monitor the LED pattern for output on the Trainor.
CODE:- USING C LANGUAGE

/*****************************************
* MDE-Win8086 EXPERIMENT PROGRAM *
* FILENAME : LED.C
* PROCESSOR : I8086
* 8255 test
*****************************************/
#include "mde8086.h"
void wait( long del )
{
while( del-- );
}
void main( void )
{
unsigned char led;
outportb( PPI1_CR, 0x80 );
outportb( PPI1_B, 0xff );
outportb( PPI1_A, 0xff );
outportb( PPI1_C, 0X20 );
led = 0xf1;
do {
outportb( PPI1_B, led );
led = led << 1;
if( led & 0x10 ) led = 0xf1;
wait( 10000 );
} while( 1);
}

Microprocessor Theory And Interfacing Lab Manual 45


CODE:- USING ASSEMBLY LANGUAGE
****************************************
; MDA-Win8086 EXPERIMENT PROGRAM *
; FILENAME : LED.ASM
; PROCESSOR : I8086
;*****************************************
CODE SEGMENT
ASSUME CS:CODE,DS:CODE,ES:CODE,SS:CODE
;
PPIC_C EQU 1FH
PPIC EQU 1DH
PPIB EQU 1BH
PPIA EQU 19H
;
ORG 1000H
MOV AL,10000000B
OUT PPIC_C,AL
;
MOV AL,11111111B
OUT PPIA,AL
;
MOV AL,00000000B
OUT PPIC,AL
;
L1: MOV AL,11110001B
L2: OUT PPIB,AL
CALL TIMER
SHL AL,1
TEST AL,00010000B
JNZ L1
OR AL,11110000B
JMP L2
;
INT 3
;
TIMER: MOV CX,1
TIMER2: PUSH CX
MOV CX,0
TIMER1: NOP
NOP

Microprocessor Theory And Interfacing Lab Manual 46


NOP
NOP
LOOP TIMER1
POP CX
LOOP TIMER2
RET
;
CODE ENDS
END

CONCLUSION:-

 In this experiment we have interfaced led’s using 8255a with mda-8086 trainer. And on

the trainer there are 4 led’s which operate by given input in the controlling program.

Activity Name 
Interfacing of led’s using 8255a interface with mda-8086
trainer
Group No.  07
Student Roll No.  8034 8035 8036 8037
C PL Domain +
No. L O Taxonomy Criteria Awarded Score (out of 4 for each cell)
O
Conduct experiments in
laboratory in order to interpret
1 A2 experimental data and displays
its conformance with analyzed
results of circuits.
-
- - - - -

Microprocessor Theory And Interfacing Lab Manual 47


Experiment # 4: Interfacing of 7-segment using
8255a interface with mda-8086 trainer.
OBJECTIVE
 To get familiar with the 7-segment display and its interfacing with 8086
microprocessor using 8255A.
EQUIPMENT
 PC having Intel microprocessor, MDA-8086 kit.
THEORY
A seven-segment display (SSD), or seven-segment indicator, is a form of electronic display
device for displaying decimal numerals. Seven-segment displays are widely used in digital
clocks, electronic meters, and other electronic devices for displaying numerical information.
Composed of seven elements. Individually on or off, they can be combined to produce
simplified representations of the numerals. Seven segment is a display which may be either
common anode or common cathode. Which is ON either on 1 or zero but here we use the
format ‘ON’ on zero.
Seven segment LED displays are often found in clock radios, VCRs, microwave ovens, toys
and many other household items. They are primarily used to display decimal numbers, but they
can also display a few alphabets and other characters. The difference between the two displays
is the common cathode has all the cathodes of the 7-segments connected directly together and
the common anode has all the anodes of the 7-segments connected together.

Microprocessor Theory And Interfacing Lab Manual 48


INTERFACING OF 8255A WITH 8086:-

Microprocessor Theory And Interfacing Lab Manual Page 49


Algorithm: Digit drive pattern
Digit drive pattern of a seven segment LED display is simply the different logic combinations of its
terminals ‘a’ to ‘h’ in order to display different digits and characters. The common digit drive patterns (0
to 9) of a seven segment display are shown in the table below.

Microprocessor Theory And Interfacing Lab Manual Page 50


Flow Chart: 7-segment display

Microprocessor Theory And Interfacing Lab Manual Page 51


PROCEDURE:-
1. Connect MDA 8085 Microprocessor Trainor with PC with Serial Port.

2. ON the MDA 8085 Microprocessor Trainor and Select Serial Monitor Mode with mode
selection switch P1 to PC

3. Run the MDA 8085 Microprocessor program.

4. Press RES button to check the connective between PC and Trainor.

5. Write the Program for 7 Segment display controlling.

6. Open the Program File.

7. Start Compiling of target application with Compile and Link button.

8. Download / load the program and then run the program.

9. Monitor the 7-segment display pattern for output on the Trainor.

C Code for 7-segment display in C Language


/*****************************************
* MDE-Win8086 EXPERIMENT PROGRAM *
* FILENAME : FND.C
* PROCESSOR : I8086
* 8255 TEST
*****************************************/
#include "mde8086.h"

int data[11] = { 0xc0, 0xf9, 0xa4, 0xb0, 0x99, 0x92,


0x82, 0xf8, 0x80, 0x90, 0x00 };

void wait(long del)


{
while( del-- );
}

void main(void)
{
int *data1;

Microprocessor Theory And Interfacing Lab Manual Page 52


outportb( PPI1_CR, 0x80 );
outportb( PPI1_B, 0xf0 );
outportb( PPI1_C, 0x00 );

do {
data1 = data;

while( *data1 != 0x00 )


{ outportb( PPI1_A, *data1
); wait(30000);
data1++;
}
}while(1);
}

Assembly Code for 7-segment display in Assembly Language


;*****************************************
; MDA-Win8086 EXPERIMENT PROGRAM *
; FILENAME : FND.ASM
; PROCESSOR : I8086
; 8255 TEST
;*****************************************
CODE SEGMENT
ASSUME CS:CODE,DS:CODE,ES:CODE,SS:CODE
;
PPIC_C EQU 1FH
PPIC EQU 1DH
PPIB EQU 1BH
PPIA EQU 19H
;
ORG 1000H
MOV AL,10000000B
OUT PPIC_C,AL
;
MOV AL,11110000B

Microprocessor Theory And Interfacing Lab Manual Page 53


OUT PPIB,AL
;
MOV AL,00000000B
OUT PPIC,AL
;
L2: MOV SI,OFFSET DATA
L1: MOV AL,BYTE PTR CS:[SI]
CMP AL,00H
JE L2
OUT PPIA,AL
CALL TIMER
INC SI
JMP L1
;
INT 3
;
TIMER: MOV CX,0
TIMER1: NOP
NOP
NOP
NOP
LOOP TIMER1
RET
;
DATA: DB 11000000B
DB 11111001B
DB 10100100B
DB 10110000B
DB 10011001B
DB 10010010B
DB 10000010B
DB 11111000B
DB 10000000B
DB 10010000B
DB 00H
CODE ENDS
END
Explanation
´ In common-anode 7-Segment LED, logic 0 is required to turn on a segment.
´ 0xc0, =11000000B =00111111(inverse)

Microprocessor Theory And Interfacing Lab Manual Page 54


´ 0xf9,=11111001B =00000110(inverse)
´ 0xa4,=10100100B =01011011(inverse)
´ 0xb0, =10110000B =01001111(inverse)
´ 0x99,=10011001B =01100110(inverse)
´ 0x92,=10010010B =01101101(inverse)
´ 0x82,=10000010B =01111101(inverse)
´ 0xf8, =11111000B =00000111(inverse)
´ 0x80,=10000000B =01111111(inverse)
´ 0x90, =10010000B =01101111(inverse)

CONCLUSION:-
 In this experiment we perform the 7-segment interfacing on mda-8086 trainer and conduct
different alphabet and digits on trainer.

Activity Name 
Interfacing of 7-segment using 8255a interface with mda-
8086 trainer.
Group No.  07
Student Roll No.  8034 8035 8036 8037
C PL Domain +
No. O Taxonomy Criteria Awarded Score (out of 4 for each cell)
L
O
Conduct experiments in
laboratory in order to interpret
1 A2 experimental data and displays
its conformance with analyzed
results of circuits.
-
- - - - -
Total

Microprocessor Theory And Interfacing Lab Manual Page 55


Experiment # 5: Introduction of Arduino.
Interface between Arduino and PC.
Integration of Arduino in Proteus.
Interfacing of LEDs with Arduino.
OBJECTIVE
 To expose student and gain more knowledge about Arduino technology.
 To increase student's thinking ability by produce new
invention EQUIPMENT
 Arduino, EPAL
 Proteus. LEDs, Connecting Leads, Potentiometer Push
Button. THEORY
What is Arduino Uno?
The Arduino Uno is a type of Arduino board that is provided as an open-source board that uses
an ATmega328p microcontroller in the board. The Arduino Uno contains a set of analog and digital
pins that are input and output pins which are used to connect the board to other components. There
are a total of fourteen I/O pins placed inboard in which six are analog input pins. The board has a
USB connection that can be used to a power supply to the board. The board is used for electronics
projects and used to design the circuit.
The Arduino UNO is categorized as a microcontroller that uses the ATmega328 as a controller
in it. The Arduino UNO board is used for an electronics project and mostly preferred by the
beginners. The Arduino UNO board I type of Arduino board only. The Arduino board is the most
used board of all Arduino boards. The board contains 14 digital input/ output pins in which 6 are
analog input pin, one power jack, USB connector, one reset button, ICSP header, and other
components. All these components are attached in the Arduino UNO board to make it function and
can be used in the project. The board is charged by USB port or can be directly charged by the DC
supply to the board.

Microprocessor Theory And Interfacing Lab Manual Page 56


Arduino Basic components, pin configuration and their feature

Microprocessor Theory And Interfacing Lab Manual Page 57


Programming jack (A TO B)

Arduino programming jack known as B typer usb port because it looks like B and using A type usb port we can
connect arduino with computer and android phone (using OTG) using A to B data cable for upload code.

Power input jack

When Arduino connect with computer using data cable


Arduino get power supply(5V) from computer so no
need
to connect external power supply, but after uploading
code, Arduino data cable can remove from Arduino
so now this power supply jack can be use.
We can apply input voltage between (7-20Vdc)

Actually, Arduino works on 5V so here use of 7805


Regulator which convert 7-20Vdc into 5 stable volts
In this picture the component under the circle is use as
regulator and here 2 capacitors of 47uF are connected in
parallel with 7805 input and output pins for filtering the
regulated 5Vdc.

Microprocessor Theory And Interfacing Lab Manual Page 58


Reverse current protection diode

The use of a reverse polarity protection diode in Arduino in series to a circuit impresses by its simplicity
and the fact that no current flows if a reverse voltage is applied. If a revers voltage is applied by mistake
so there will be no issues in Arduino board.
There are some drawbacks regarding this solution, however. The voltage drop over the diode is around
0.7 V for a normal silicon diode. This is especially an issue with low supply voltage.

Op-Amp IC (Comparator)

This IC is used for when data cable and external power supply are connected at the same time, so this IC compare
voltage and allows one voltage to pass.

Microprocessor Theory And Interfacing Lab Manual Page 59


3.3 V regulator with filtering capacitors
Here in Arduino one 3.3V regulator IC is also connected to convert 5V to 3.3V and two capacitors also
connected with input and output of 3.3V regulator for filtering the voltages.

USB to TTL serial converter IC

In Arduino ATMega16U2 is used for USB to TTL converter because microcontroller cannot understand USB
language directly, we can upload program in ATMega328P without using ATMega16U2 IC by using external USB
to TTL device (ch340).

ICSP header
ICSP stands for In-Circuit Serial Programming. The name originated from In-System Programming
headers (ISP). Manufacturers like Atmel who work with Arduino have developed their own in-circuit
serial programming headers. These pins enable the user to program the Arduino boards’ firmware. There

Microprocessor Theory And Interfacing Lab Manual Page 60


are six ICSP pins available on the Arduino board that can be hooked to a programmer device via a
programming cable.

 Reset button
When reset button press program will run from beginning with initial values.

ICSP for SPI interface


SPI(serial peripheral interface) is an interface by which two or more microcontroller transfer data with
each other or one microcontroller and other devices having SPI interface can transfer data.

Microprocessor Theory And Interfacing Lab Manual Page 61


In short, these pins are used for the master slave respective and also used for the bootloader upload and
burn.

Microcontroller IC

The ATmega328 is a single-chip microcontroller created by Atmel in the megaAVR family (later
Microchip Technology acquired Atmel in 2016) and use in Arduino board as a microcontroller.
Pin configuration with respect to Arduino
Here input voltage value is with respect to the Arduino because actually that microcontroller is worked
on 5Vdc, but Arduino board have a 5V regulator.

Microprocessor Theory And Interfacing Lab Manual Page 62


Complete introduction of ATmega328

ATmega328 is an 8-bit, 28-Pin AVR Microcontroller, manufactured by Microchip, follows RISC


Architecture, and has a flash-type program memory of 32KB.
Atmega328 is the microcontroller, used in basic Arduino boards i.e Arduino UNO, Arduino Pro Mini
and Arduino Nano.
It has an EEPROM memory of 1KB and its SRAM memory is 2KB.
It has 8 Pins for ADC operations, which all combine to form PortA ( PA0 – PA7 ).
It also has 3 built-in Timers, two of them are 8 Bit timers while the third one is 16-Bit Timer.
You must have heard of Arduino UNO, UNO is based on atmega328 Microcontroller. It’s

UNO’sheart.
It operates ranging from 3.3V to 5.5V but normally we use 5V as a standard.
Its excellent features include cost-efficiency, low power dissipation, programming lock for security
purposes, real timer counter with separate oscillator.
It’s normally used in Embedded System applications. You should have a look at these Real Life
Examples of Embedded Systems, we can design all of them using this Microcontroller.

ATmega328 Pins
ATmega-328 is an AVR Microcontroller having twenty-eight (28) pins in total.
All of the pins in chronological order, are listed in the table shown in the figure given below.

Now let’s have a look at the pinout of Atmega328 in detail:


ATmega328 pinout diagram is shown in the figure given below:

ATmega328 Pins Description


Functions associated with the pins must be known in order to use the device appropriately.

Microprocessor Theory And Interfacing Lab Manual Page 63


ATmega-328 pins are divided into different ports which are given in detail below.
VCC is a digital voltage supply.
AVCC is a supply voltage pin for analog to digital converter.
GND denotes Ground and it has a 0V.
Port A consists of the pins from PA0 to PA7. These pins serve as an analog input to analog to digital
converters. If analog to digital converter is not used, port A acts as an eight (8) bit bidirectional
input/output port.
Port A is the ADC 'port'.
Port B consists of the pins from PB0 to PB7. This port is an 8 bit bidirectional port having an internal
pull-up resistor.
Port C consists of the pins from PC0 to PC7. The output buffers of port C has symmetrical drive
characteristics with source capability as well high sink.
Port D consists of the pins from PD0 to PD7. It is also an 8 bit input/output port having an internal pull-
up resistor.
Power pins
There is a section of power pins on the Arduino Uno board here Vin pin is used for the input 5Vdc
rather than the USB nor power jack supplies.
And here you can see 5V and 3.3V pins these pins are used for the output voltage which used for the
other circuitries like 3.3V is used for the ESP826(WIFI module) as a power source.

RESET pin

IOREF pin

Microprocessor Theory And Interfacing Lab Manual Page 64


This pin on the Arduino board provides the voltage reference with which the microcontroller operates. A
properly configured shield can read the IOREF pin voltage and select the appropriate power source or
enable voltage translators on the outputs to work with the 5V or 3.3V.

Analog pins

Arduino boards contain a multichannel, 10-bit analog to digital converter. This means that it will map
input voltages between 0 and the operating voltage (5V or 3.3V) into integer values between 0 and
1023.Arduino Uno board have 6 analog pins (A0-A5). And these pins are also used as digital input
output purpose.

Here A4 and A5 pins are also used as TWI pins

TWI pins
The Two-Wire Interface (TWI) is similar to the I2C interface with a few differences. The TWI
peripheral provides an interface to components on a unique two-wire bus, consisting of one clock
line and one data line.

Microprocessor Theory And Interfacing Lab Manual Page 65


Arduino boards to share information with each other.....The I2C protocol involves using two lines to
send and receive data: a serial clock pin (SCL) that the Arduino Master board pulses at a regular
interval, and a serial data pin (SDA) over which data is sent between the two devices.

Digital pins
Arduino Uno is a microcontroller board based on the ATmega328P. It has 14 digital input/output pins
(of which 6 can be used as PWM outputs)

PWM pins
Pulse Width Modulation, or PWM, is a technique for
getting analog results with digital means. Digital
control is used to create a square wave, a signal
switched between on and off. ... The duration of "on
time" is called the pulse width. To get varying analog
values, you change, or modulate, that pulse width.

Microprocessor Theory And Interfacing Lab Manual Page 66


Digital pins 10,11,12,13 are also
used as SPI protocol

Analog reference pin


This pin is used for the analog reference voltage for ADC (build in Arduino)
DEFAULT: the default analog reference of 5 volts (on 5V Arduino boards) or 3.3 volts (on 3.3V
Arduino boards)
INTERNAL: a built-in reference, equal to 1.1 volts on the ATmega168 or ATmega328P and 2.56 volts
on the ATmega32U4 and ATmega8 (not available on the Arduino Mega)
EXTERNAL: the voltage applied to the AREF pin (0 to 5V only) is used as the reference.

Installing the Integrated Development Environment (IDE)

Problem 01

You want to install Arduino IDE on your computer.

Microprocessor Theory And Interfacing Lab Manual Page 67


First download IDE from that link https://www.arduino.cc/en/software

Go to download folder and install it.

Open the IDE that is working area for coding and happy coding

Microprocessor Theory And Interfacing Lab Manual Page 68


Go to the file>Examples>Basics>Blink

Upload code in Arduino


Open IDE window and go to

Microprocessor Theory And Interfacing Lab Manual Page 69


File>Preference>click on compilation>ok

Then go to the file>Examples>Basics>Blink, Then compile it


Go to console window and copy that path of its Hex file (Selected path)

Microprocessor Theory And Interfacing Lab Manual Page 70


You can also use Arduino Uno in Proteus just adding the Arduino Uno library in the libraries of
Proteus

First download Arduino library from here https://github.com/Proteus-LIBRARY/Arduino-Library


And then go to code>Download Zip

Before adding Arduino library in Proteus

Now unzip this file and copy these files

After Unzip copy these files

Go to this location and past these two files here

C:\Program Files (x86)\Labcenter Electronics\Proteus 8 Professional\Library

Microprocessor Theory And Interfacing Lab Manual Page 71


Now After adding Library

Double click on Arduino and open a new window go to program file and paste here hex file path

Microprocessor Theory And Interfacing Lab Manual Page 72


After pasting complete path click on OK

Microprocessor Theory And Interfacing Lab Manual Page 73


Now run the simulation After pasting and interfacing the required components (LED, GND)

2nd method to upload code in Arduino which is little bit easy for you
Copy all code from IDE

// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(LED_BUILTIN, OUTPUT);
}

// the loop function runs over and over again forever


void loop() {

Microprocessor Theory And Interfacing Lab Manual Page 74


digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage
level) delay(1000); // wait for a second
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage
LOW delay(1000); // wait for a second
}

Go to Proteus file and right click on Arduino > Edit source code & paste code here

Run simulation

Microprocessor Theory And Interfacing Lab Manual Page 75


Procedure:

1. Construct /assemble circuit of required task.

2. Connect the Arduino board to your computer using the USB cable.

Microprocessor Theory And Interfacing Lab Manual Page 76


3. Select the board and serial port as outlined in earlier section.

4. Write code of required task.

5. Verify / compile code and upload / run the code button to send sketch to the Arduino.

Circuit Diagram:

Microprocessor Theory And Interfacing Lab Manual Page 77


CONCLUSION:-
 In this experiment we learned a lot about Arduino, its interfacing with pc.
 And also interfacing of led’s with Arduino.

Introduction of Arduino.
Interface between Arduino and PC
Activity Name 
Integration of Arduino in Proteus
Interfacing of LEDs with Arduino.

Group No.  07
Student Roll No.  8034 8035 8036 8037
C PL Domain +
No. O Taxonomy Criteria Awarded Score (out of 4 for each cell)
L
O
Conduct experiments in
laboratory in order to interpret
1 A2 experimental data and displays
its conformance with analyzed
results of circuits.
-
- - - - -
Total

Microprocessor Theory And Interfacing Lab Manual Page 78


Experiment # 6: Interfacing Of 7-Segment With
Arduino Uno

OBJECTIVE
 To expose student and gain more knowledge about 7-Segment Technology

EQUIPMENT
 Arduino IDE
 Proteus
 7-Segment
 Resistor
THEORY
What is 7-Segment display?
A seven-segment display (SSD), or seven-segment indicator, is a form of electronic display device for
displaying decimal numerals. Seven-segment displays are widely used in digital clocks, electronic
meters, and other electronic devices for displaying numerical information. Composed of seven elements.
Individually on or off, they can be combined to produce simplified representations of the numerals.
Seven segment is a display which may be either common anode or common cathode. Which is ON
either on 1 or zero but here we use the format ‘ON’ on zero.
Seven segment LED displays are often found in clock radios, VCRs, microwave ovens, toys and many
other household items. They are primarily used to display decimal numbers, but they can also display a
few alphabets and other characters. The difference between the two displays is the common cathode has
all the cathodes of the 7-segments connected directly together and the common anode has all the anodes
of the 7-segments connected together. Seven-segment LED is a digital display module specialized to
display numerical information. Light-emitting diodes (LEDs) arranged in the shape of numbers offer an
easily visible display. They are sometimes called "seven-segment displays" or "seven-segment
indicators."

Microprocessor Theory And Interfacing Lab Manual Page 79


A display consisting of seven LEDs arranged in seven segments is called seven segment display. It is
shown in the Fig. The seven LEDs are arranged in a rectangular fashion and are labeled A through G.
Each LED is called a segment because it forms a part of the digit being displayed. An additional LED is
used for the indication of a decimal point (DP). By forward biasing different LEDs we can display the
digits 0 through 9. For example, to display a zero, the LEDs A, B, C, D, E and F are forward biased. To
light up a 5, we need to forward bias segments A, F, C, C, D. Thus in a seven segment display
depending upon the digit to be displayed, the particular set of LEDs is forward biased. The various digits
from 0 to 9 which can be displayed using seven segment display are shown in the Fig

Types of 7-Segment display


The two types of seven segment display are available called,
Common anode type
Common Anode Type, all anodes of LEDs are connected together, and common point is connected to +
V which is positive supply voltage. A current limiting resistor is required to be connected between each
LED and ground

Microprocessor Theory And Interfacing Lab Manual Page 80


Common Cathode
In this type, all cathodes of LEDs are connected together, and common point is connected to the ground.
A current limiting resistor is connected between each LED and the supply +Vcc. The anodes of the
respective segments are to be connected to + for the required operation of LEDs.

Algorithm: Digit drive pattern


Digit drive pattern of a seven segment LED display is simply the different logic combinations of its
terminals ‘a’ to ‘h’ in order to display different digits and characters. The common digit drive patterns (0
to 9) of a seven segment display are shown in the table below.

Microprocessor Theory And Interfacing Lab Manual Page 81


Explanation
´ In common-anode 7-Segment LED, logic 0 is required to turn on a segment.
Digit Code in Common Code in Hex Code in Common Code in Hex
Cathode CCC Anode CAC
0 00111111 0x3f 11000000 0xc0
1 00000110 0x06 11111001 0xf9
2 01011011 0x5b 10100100 0xa4
3 01001111 0x4f 10110000 0xb0
4 01100110 0x66 10011001 0x99
5 01101101 0x6d 10010010 0x92
6 01111101 0x7d 10000010 0x82
7 00000111 0x07 11111000 0xf8
8 01111111 0x7f 10000000 0x80
9 01101111 0x6f 10010000 0x90
HOW IT WORKS

A seven-segment LED display shows a single digit or character using LED segments. Each
segment is an individual LED, and by controlling which segments are lit at any time, we can display
numeric values. We’re using a single-digit display in this project, shown in Figure, but there are also
two-, three-, four-, and eight-digit variations available.
NOTE
The cathode of a device is the negative connection, usually indicated with a minus sign (–) and
sometimes referred to as ground (abbreviated GND). It is connected to negative power. The anode of a
device is the positive connection, usually indicated with a plus sign (+) and connected to positive power.

Microprocessor Theory And Interfacing Lab Manual Page 82


This project will create a simple timer to count down from
9 to 0. The seven-segment LED has 10 pins. Seven pins
control the seven LEDs that light up to form each digit, and
the eighth pin controls the decimal point. The other two
pins are the common-cathode (–) or common-anode (+)
pins, which add power to the project. Our seven-segment
LED is common cathode, meaning one side of each LED
needs to connect to ground. It’s important to note that the
code will work only with a common-cathode LED. If you
have a common-anode LED you want to use, check the
troubleshooting section at the end of this chapter before
uploading the sketch. Each LED segment requires a
resistor to limit the current; otherwise, it will burn out. The pins are labeled with a letter, as shown in
Figure 3-2. The numbered pins control the segments as shown on the right. The Arduino creates the
number by turning the LEDs off or on in different combinations.
Adding the library of 7-Segment in Arduino IDE
Open Arduino IDE window > Tools > Manage libraries then click on here, go to this
window

Then write library name in searching bar

(sevseg)

Microprocessor Theory And Interfacing Lab Manual Page 83


and install latest version of library

Project On Proteus

Code :
#define a 3
#define b 4
#define c 5
#define d 6
#define e 7
#define f 8
#define g 9
#define h 10
void setup() {
Serial.begin(9600);
pinMode(a, OUTPUT);
pinMode(b, OUTPUT);
pinMode(c, OUTPUT);
pinMode(d, OUTPUT);
pinMode(e, OUTPUT);
pinMode(f, OUTPUT);
pinMode(g, OUTPUT);
pinMode(h, OUTPUT);
}
void loop()
{ digitalWrite(a,LOW);
digitalWrite(b,LOW);
digitalWrite(c,LOW);
digitalWrite(d,HIGH);
digitalWrite(e,HIGH);
digitalWrite(f,HIGH);
digitalWrite(g,HIGH);
digitalWrite(h,LOW);
delay(1000);
}

Arduino pin Seven Segment Seven Segment LED


LED Section Display
PIN 3 a PIN 7
PIN 4 b PIN 6
PIN 5 c PIN 4
PIN 6 d PIN 2
PIN 7 e PIN 1
PIN 8 f PIN 10
PIN 9 g PIN 9
PIN 10 dp PIN 5

Microprocessor Theory And Interfacing Lab Manual Page 84


CONCLUSION:
 In this experiment we understood the interfacing of Ardiuno with 7-segment using a
breadboard.
 And display the digits and alphabet on 7-segment while giving the instrucstion through ardiuno.

Activity Name  Interfacing Of 7-Segment With Arduino Uno


Group No.  07
Student Roll No.  8034 8035 8036 8037
C P Domain +
No. L L Taxonomy Criteria Awarded Score (out of 4 for each cell)
O O
Conduct experiments in
laboratory in order to
interpret experimental data
1 A2 and displays its conformance
with analyzed results of
circuits.
-
- - - - -
Total

Microprocessor Theory And Interfacing Lab Manual Page 85


Experiment # 7: Interfacing of LCD module
with Arduino
OBJECTIVE
 To expose student and gain more knowledge about LCD module interface
with Arduino.

EQUIPMENT
 Arduino IDE
 LCD 16x2
 Connecting Leads
 Variable Resistor

THEORY
What is LCD 16X2?

An electronic device that is used to display data and the message is known as LCD 16×2. As the
name suggests, it includes 16 Columns & 2 Rows so it can display 32 characters (16×2=32) in total
& every character will be made with 5×8 (40) Pixel Dots. So the total pixels within this LCD can
be calculated as 32 x 40 otherwise 1280 pixels.

LCD 16 X2

16 X2 displays mostly depend on multi-segment LEDs. There are different types of displays
available in the market with different combinations such as 8×2, 8×1, 16×1, and 10×2, however,

Microprocessor Theory And Interfacing Lab Manual Page 86


the LCD 16×2 is broadly used in devices, DIY circuits, electronic projects due to less cost,
programmable friendly & simple to access.

Specifications of LCD 16X2


The specifications of LCD 16X2 are discussed below.

 The operating voltage of this display ranges from 4.7V to 5.3V


 The display bezel is 72 x 25mm
 The operating current is 1mA without a backlight
 PCB size of the module is 80L x 36W x 10H mm
 HD47780 controller
 LED color for backlight is green or blue
 Number of columns – 16
 Number of rows – 2
 Number of LCD pins – 16
 Characters – 32
 It works in 4-bit and 8-bit modes
 Pixel box of each character is 5×8 pixel
 Font size of character is 0.125Width x 0.200height

LCD 16X2 Pin Configuration

The pin configuration of LCD 16 X 2 is discussed below so that LCD 16×2 connection can be done
easily with external devices.

16X2 LCD Pin Diagram

 Pin1 (Ground): This pin connects the ground terminal.


 Pin2 (+5 Volt): This pin provides a +5V supply to the LCD

Microprocessor Theory And Interfacing Lab Manual Page 87


 Pin3 (VE): This pin selects the contrast of the LCD.
 Pin4 (Register Select): This pin is used to connect a data pin of an MCU & gets either 1 or
0. Here, data mode = 0 and command mode =1.
 Pin5 (Read & Write): This pin is used to read/write data.
 Pin6 (Enable): This enables the pin must be high to perform the Read/Write procedure.
This pin is connected to the data pin of the microcontroller to be held high constantly.
 Pin7 (Data Pin): The data pins are from 0-7 which are connected through the
microcontroller for data transmission. The LCD module can also work on the 4-bit mode
through working on pins 1, 2, 3 & other pins are free.
 Pin8 – Data Pin 1
 Pin9 – Data Pin 2
 Pin10 – Data Pin 3
 Pin11 – Data Pin 4
 Pin12 – Data Pin 5
 Pin13 – Data Pin 6
 Pin14 – Data Pin 7
 Pin15 (LED Positive): This is a +Ve terminal of the backlight LED of the display & it is
connected to +5V to activate the LED backlight.
 Pin16 (LED Negative): This is a -Ve terminal of a backlight LED of the display & it is
connected to the GND terminal to activate the LED backlight.

Sr. Pin
Pin Name Pin Type Pin Description Pin Connection
No No.

Pin This is a ground pin of Connected to the ground of


1 Ground Source Pin
1 LCD the MCU/ Power source

Pin This is the supply Connected to the supply pin


2 VCC Source Pin
2 voltage pin of LCD of Power source

Pin Adjusts the contrast of Connected to a variable


S3 V0/VEE Control Pin
3 the LCD. POT that can source 0-5V

Connected to a MCU pin


Toggles between
Pin Register and gets either 0 or 1. 0 ->
4 Control Pin Command/Data
4 Select Command Mode 1-> Data
Register
Mode

Connected to a MCU pin


Toggles the LCD
Pin and gets either 0 or 1. 0 ->
5 Read/Write Control Pin between Read/Write
5 Write Operation 1-> Read
Operation
Operation

6 Pin Enable Control Pin Must be held high to Connected to MCU and

Microprocessor Theory And Interfacing Lab Manual Page 88


6 perform Read/Write always held high.
Operation

In 4-Wire Mode Only 4


Pin Pins used to send pins (0-3) is connected to
Data Bits Data/Command
7 7- Command or data to the MCU In 8-Wire Mode All
(0-7) Pin
14 LCD. 8 pins(0-7) are connected to
MCU

Normal LED like


Pin LED
8 LED Pin operation to illuminate Connected to +5V
15 Positive
the LCD

Normal LED like


Pin LED operation to illuminate
9 LED Pin Connected to ground
16 Negative the LCD connected with
GND.

Working Principle
The basic working principle of LCD is passing the light from layer to layer through modules. These
modules will vibrate & line up their position on 90 o that permits the polarized sheet to allow the
light to pass through it.

These molecules are accountable for viewing the data on every pixel. Every pixel utilizes the
method of absorbing light to illustrate the digit. To display the value, the position of molecules
must be changed to the angle of light.

So this light deflection will make the human eye notice the data that will be the ingredient
wherever the light gets absorbed. Here, this data will supply to the molecules & will be there till
they get changed
At present, LCDs are used frequently in CD/DVD players, digital watches, computers, etc. In
screen industries, LCDs have replaced the CRTs (Cathode Ray Tubes) because these displays use
more power as compared to LCD, heavier & larger.

The displays of LCDs are thinner as compared to CRTs. As compared to LED screens, LCD has
less power consumption because it functions on the fundamental principle of blocking light instead
of dissipating.

Microprocessor Theory And Interfacing Lab Manual Page 89


Registers of LCD

The registers used in LCD are two types like data register & command register. The register can
be changed by using the RS pinout. If we set ‘0’ then it is command register and if it is ‘1’ then it
is data register.

Command Register

The main function of the command register is to save instructions illustrated on LCD. That assists
in data clearing & changes the cursor location & controls the display.

Data Register

The data register is used to save the date to exhibit on the LCD. Once we transmit data to LCD,
then it shifts to the data register to process the data. If we fix the register value at one that the data
register will start working.

It is okay if you do not understand the function of all the pins, I will be explaining in detail below. Now,
let us turn back our LCD:

Okay, what is this two black circle like things on the back of our LCD?
These black circles consist of an interface IC and its associated components to help us use this LCD with
the MCU. Because our LCD is a 16*2 Dot matrix LCD and so it will have (16*2=32) 32 characters in
total and each character will be made of 5*8 Pixel Dots. A Single character with all its Pixels enabled is
shown in the below picture.

Microprocessor Theory And Interfacing Lab Manual Page 90


So Now, we know that each character has (5*8=40) 40 Pixels and for 32 Characters we will have
(32*40) 1280 Pixels. Further, the LCD should also be instructed about the Position of the Pixels.
It will be a hectic task to handle everything with the help of MCU, hence an Interface IC like
HD44780 is used, which is mounted on LCD Module itself. The function of this IC is to get
the Commands and Data from the MCU and process them to display meaningful information onto our
LCD Screen.
Let’s discuss the different type of mode and options available in our LCD that has to be controlled by
our Control Pins.
4-bit and 8-bit Mode of LCD:
The LCD can work in two different modes, namely the 4-bit mode and the 8-bit mode. In 4 bit mode we
send the data nibble by nibble, first upper nibble and then lower nibble. For those of you who don’t
know what a nibble is: a nibble is a group of four bits, so the lower four bits (D0-D3) of a byte form the
lower nibble while the upper four bits (D4-D7) of a byte form the higher nibble. This enables us to send
8 bit data.
Whereas in 8 bit mode we can send the 8-bit data directly in one stroke since we use all the 8 data lines.
Now you must have guessed it, Yes 8-bit mode is faster and flawless than 4-bit mode. But the major
drawback is that it needs 8 data lines connected to the microcontroller. This will make us run out of I/O
pins on our MCU, so 4-bit mode is widely used. No control pins are used to set these modes. It's just the
way of programming that change.

Interfacing LCD 16×2 with Arduino

Interfacing of a 16X2 LCD with Arduino is discussed to display “Hello World!” on the screen. A
library like LiquidCrystal permits you to manage the displays that are well-matched through the
driver like Hitachi HD44780 driver. Here, the following example circuit displays “Hello World!”
on the LCD & displays the time in sec once the Arduino board was reset.

The 16×2 display includes a parallel interface which means that the microcontroller used in this
has to control different interface pins immediately to control the LCD. The interface includes
mainly these pins like RS (Register Select) pin, Read/Write pin, Enable Pin, Data pins from D0 to
D7, display contrast pin, LED backlight pins, power supply pins.

The display controlling process mainly involves placing the data to form the picture of what you
desire to show into the data registers, after that placing instructions within the instruction

Microprocessor Theory And Interfacing Lab Manual Page 91


register. A library like LiquidCrystal will simplify this for you so you don’t require identifying the
instructions in low-level.

The controlling of LCDs compatible with Hitachi can be done using two modes like 4-bit/8-bit.
Here, the 4-bit mode needs 7 I/O pins using the Arduino board, whereas the 8-bit mode needs 11
pins. To display the text on the LCD, the 4-bit mode is used. The following example will explain
how to control an LCD using 4-bit mode.

Liquid Crystal Library


This library allows an Arduino board to control LiquidCrystal displays
(LCDs) based on the Hitachi HD44780 (or a compatible) chipset, which is
found on most text-based LCDs. The library works with in either 4- or 8-
bit mode (i.e. using 4 or 8 data lines in addition to the rs, enable, and,
optionally, the rw control lines).

To use this library


#include <LiquidCrystal.h>
Examples
 Autoscroll: Shift text right and left.
 Blink: Control of the block-style cursor.
 Cursor: Control of the underscore-style cursor.
 Display: Quickly blank the display without losing what's on it.
 Hello World: Displays "hello world!" and the seconds since reset.
 Scroll: Scroll text left and right.
 Serial Display: Accepts serial input, displays it.
 Set Cursor: Set the cursor position.

 Text Direction: Control which way text flows from the cursor.
LiquidCrystal()
Description
Creates a variable of type LiquidCrystal. The display can be controlled using 4 or 8
data lines. If the former, omit the pin numbers for d0 to d3 and leave those lines

Microprocessor Theory And Interfacing Lab Manual Page 92


unconnected. The RW pin can be tied to ground instead of connected to a pin on the
Arduino; if so, omit it from this function's parameters.

Syntax
LiquidCrystal (rs, enable, d4, d5, d6, d7)
LiquidCrystal (rs, rw, enable, d4, d5, d6, d7)
LiquidCrystal (rs, enable, d0, d1, d2, d3, d4, d5, d6, d7)
LiquidCrystal (rs, rw, enable, d0, d1, d2, d3, d4, d5, d6, d7)

Parameters
rs: the number of the Arduino pin that is connected to the RS pin on the LCD
rw: the number of the Arduino pin that is connected to the RW pin on the LCD
(optional)
enable: the number of the Arduino pin that is connected to the enable pin on the LCD
d0, d1, d2, d3, d4, d5, d6, d7: the numbers of the Arduino pins that are connected to the
corresponding data pins on the LCD. d0, d1, d2, and d3 are optional; if omitted, the
LCD will be controlled using only the four data lines (d4, d5, d6, d7).

Example LiquidCrystal (rs, enable, d4, d5, d6, d7)


#include <LiquidCrystal.h>

LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2);

void setup()
{
lcd.begin(16,1);
lcd.print("hello, world!");
}

void loop() {}

begin()
Description
Initializes the interface to the LCD screen, and specifies the dimensions (width and
height) of the display. begin() needs to be called before any other LCD library
commands.
Syntax
lcd.begin(cols, rows)
Parameters
lcd: a variable of type LiquidCrystal

Microprocessor Theory And Interfacing Lab Manual Page 93


cols: the number of columns that the display has
rows: the number of rows that the display has

------------------------------------------------------------------------------------------------------

clear()
Description
Clears the LCD screen and positions the cursor in the upper-left corner.
Syntax
lcd.clear()
Parameters
lcd: a variable of type LiquidCrystal
-------------------------------------------------------------------------------------------------------
home()
Description
Positions the cursor in the upper-left of the LCD. That is, use that location in
outputting subsequent text to the display. To also clear the display, use
the clear() function instead.
Syntax
lcd.home()
Parameters
lcd: a variable of type LiquidCrystal
-------------------------------------------------------------------------------------------------------
setCursor()
Description
Position the LCD cursor; that is, set the location at which subsequent text written to the
LCD will be displayed.
Syntax
lcd.setCursor(col, row)
Parameters
lcd: a variable of type LiquidCrystal
col: the column at which to position the cursor (with 0 being the first column)
row: the row at which to position the cursor (with 0 being the first row)
-------------------------------------------------------------------------------------------------------
write()
Description
Write a character to the LCD.
Syntax
lcd.write(data)

Microprocessor Theory And Interfacing Lab Manual Page 94


Parameters
lcd: a variable of type LiquidCrystal
data: the character to write to the display
Returns
byte
write() will return the number of bytes written, though reading that number is optional
Example
#include <LiquidCrystal.h>

LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2);

void setup()
{
Serial.begin(9600);
}

void loop()
{
if (Serial.available())
{ lcd.write(Serial.read()
);
}
-------------------------------------------------------------------------------------------------------
print()
Description
Prints text to the LCD.
Syntax
lcd.print(data)
lcd.print(data, BASE)
Parameters
lcd: a variable of type LiquidCrystal
data: the data to print (char, byte, int, long, or string)
BASE (optional): the base in which to print numbers: BIN for binary (base 2), DEC for
decimal (base 10), OCT for octal (base 8), HEX for hexadecimal (base 16).
Returns
byte
print() will return the number of bytes written, though reading that number is optional
Example
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2);
void setup()
{
lcd.print("hello, world!");
}

Microprocessor Theory And Interfacing Lab Manual Page 95


void loop() {}
-------------------------------------------------------------------------------------------------------
cursor()
Description
Display the LCD cursor: an underscore (line) at the position to which the next
character will be written.
Syntax
lcd.cursor()
Parameters
lcd: a variable of type LiquidCrystal
Example
 cursor()
------------------------------------------------------------------------------------------------
noCursor()
Description
Hides the LCD cursor.
Syntax
lcd.noCursor()
Parameters
lcd: a variable of type LiquidCrystal
Example
 noCursor()
------------------------------------------------------------------------------------------------
blink()
Description
Display the blinking LCD cursor. If used in combination with the cursor() function, the
result will depend on the particular display.
Syntax
lcd.blink()
Parameters
lcd: a variable of type LiquidCrystal
Example
 blink() and noBlink()
------------------------------------------------------------------------------------------------
noBlink()
Description
Turns off the blinking LCD cursor.
Syntax
lcd.noBlink()

Microprocessor Theory And Interfacing Lab Manual Page 96


Parameters
lcd: a variable of type LiquidCrystal
Example
 blink() and noBlink()
------------------------------------------------------------------------------------------------
display()
Description
Turns on the LCD display, after it's been turned off with noDisplay(). This will restore
the text (and cursor) that was on the display.
Syntax
lcd.display()
Parameters
lcd: a variable of type LiquidCrystal
Example
 display() and noDisplay()
------------------------------------------------------------------------------------------------
noDisplay()
Description
Turns off the LCD display, without losing the text currently shown on it.
Syntax
lcd.noDisplay()
Parameters
lcd: a variable of type LiquidCrystal
Example
 display() and noDisplay()
------------------------------------------------------------------------------------------------
scrollDisplayLeft()
Description
Scrolls the contents of the display (text and cursor) one space to the left.
Syntax
lcd.scrollDisplayLeft()
Parameters
lcd: a variable of type LiquidCrystal
Example
 scrollDisplayLeft() and scrollDisplayRight()
------------------------------------------------------------------------------------------------

Microprocessor Theory And Interfacing Lab Manual Page 97


scrollDisplayRight()
Description
Scrolls the contents of the display (text and cursor) one space to the right.
Syntax
lcd.scrollDisplayRight()
Parameters
lcd: a variable of type LiquidCrystal
Example
 scrollDisplayLeft() and scrollDisplayRight()
------------------------------------------------------------------------------------------------
autoscroll()
Description
Turns on automatic scrolling of the LCD. This causes each character output to the
display to push previous characters over by one space. If the current text direction is
left-to-right (the default), the display scrolls to the left; if the current direction is right-
to-left, the display scrolls to the right. This has the effect of outputting each new
character to the same location on the LCD.
Syntax
lcd.autoscroll()
Parameters
lcd: a variable of type LiquidCrystal
------------------------------------------------------------------------------------------------
noAutoscroll()
Description
Turns off automatic scrolling of the LCD.
Syntax
lcd.noAutoscroll()
Parameters
lcd: a variable of type LiquidCrystal
------------------------------------------------------------------------------------------------
leftToRight()
Description
Set the direction for text written to the LCD to left-to-right, the default. This means
that subsequent characters written to the display will go from left to right, but does not
affect previously-output text.
Syntax
lcd.leftToRight()

Microprocessor Theory And Interfacing Lab Manual Page 98


Parameters
lcd: a variable of type LiquidCrystal
------------------------------------------------------------------------------------------------
rightToLeft()
Description
Set the direction for text written to the LCD to right-to-left (the default is left-to-right).
This means that subsequent characters written to the display will go from right to left,
but does not affect previously-output text.
Syntax
lcd.rightToLeft()
Parameters
lcd: a variable of type LiquidCrystal
------------------------------------------------------------------------------------------------

Procedure:
6. Construct /assemble circuit of required task.

7. Connect the Arduino board to your computer using the USB cable.

8. Select the board and serial port as outlined in earlier section.

9. Write code of required task.

10.Verify / compile code and upload / run the code button to send sketch to the
Arduino.

11.Check the result of the required Task.

12.Save the result and attached with Report.

Microprocessor Theory And Interfacing Lab Manual Page 99


Circuit Diagram:

Microprocessor Theory And Interfacing Lab Manual Page


CONCLUSION: -
 We perform this experiment, learn about LCD, its pins and their working. First we add
LCD library in Arduino.
 After adding library we coding in Arduino and then copy hex file for proteus. Create circuit
in proteus and paste hex file in program file. Run the circuit and shown output.

Activity Name  Interfacing of LCD module with Arduino


Group No.  07
Student Roll No.  8034 8035 8036 8037
C P Domain +
No. L L Taxonomy Criteria Awarded Score (out of 4 for each cell)
O O
Conduct experiments in
laboratory in order to
interpret experimental data
1 A2 and displays its conformance
with analyzed results of
circuits.
-
- - - - -
Total

Microprocessor Theory And Interfacing Lab Manual Page


Experiment No. 09
INTERFACING OF MOTOR (SPEED CONTROLLING) WITH ARDUINO

OBJECTIVE
 Implementation of DC motor interface with Arduino.
 Implementation of Servo motor interface with Arduino.
 Implementation of Stepper motor interface with Arduino.

EQUIPMENT
 Arduino
 DC motor
 Servo motor
 Stepper motor
DC MOTOR

THEORY
DC motor has part of many equipment and machinery. We are using 5v DC motor, It is device that can
use in industrial equipment as small device and it also chipper and used in robotics, Quadcopter, and
internet of the things project. DC motor work on the current and voltage needed for the capabilities of
microcontroller but DC moto necessary to use some external device of electronic to drive the and control
the motor and it required individual power supply. There are many ways to drive the DC motor from
their output of device. however, transistor also use full to drive the DC motor and the other way to
control the direction of the motor is L298 drive it is integrated circuit.
How DC motor work

Microprocessor Theory And Interfacing Lab Manual Page


DC motor has two main part stator, rotor and armature. The stator is permanent management and it has
magnetic field and the rotating part called armature simple coil. Here armature is connected to DC
power supply and 2-piece ring fixed in motor shaft, this section called ‘commutator ring. DC applied to
the commutator where flow passes through the coil it generated magnetic field.
A DC motor (Direct Current motor) is the most common type of motor. DC motors normally have just
two leads, one positive and one negative. If you connect these two leads directly to a battery, the motor
will rotate. If you switch the leads, the motor will rotate in the opposite direction.

Warning − Do not drive the motor directly from Arduino board pins. This may damage the
board. Use a driver Circuit or an IC.
We will divide this chapter into three parts −

 Just make your motor spin


 Control motor speed
 Control the direction of the spin of DC motor
Precautions
Take the following precautions while making the connections.
 First, make sure that the transistor is connected in the right way. The flat side of the
transistor should face the Arduino board as shown in the arrangement.
 Second, the striped end of the diode should be towards the +5V power line according
to the arrangement shown in the image.

Microprocessor Theory And Interfacing Lab Manual Page


Speed Control of DC Motor PWM – For controlling speed
The speed of a DC motor can be controlled by varying its input voltage. A common
technique for doing this is to use PWM (Pulse Width Modulation) PWM is a technique where average
value of the input voltage is adjusted by sending a series of ON-OFF pulses.

the averages voltage is proportional to the width of the pulses known as Duty Cycle. The higher the duty
cycle, the greater the average voltage being applied to the dc motor (High Speed) and the lower the duty
cycle, the less the average voltage being applied to the dc motor (Low Speed). Below image illustrates
PWM technique with various duty cycles and average voltages.

Microprocessor Theory And Interfacing Lab Manual Page


/

Microprocessor Theory And Interfacing Lab Manual Page


Speed Control with RF520 MOSFET Driver Module
This module controls DC motors by PWM (Pulse Width Modulation) technique. These modules
convert a constant input voltage to a variable voltage. DC Motor’s speed can also be controlled by
changing the voltage across it. PWMs usually have a constant frequency and can control the
engine speed by controlling the length of time that the pulse is HIGH (Duty Cycle)
Note
DC motor’s voltage can be 0 to 24 volts and the maximum current can be up to 5A. In high
currents heatsink is required.
IRF520 MOSFET Driver Module Pinout
This sensor has 7 pins:
 VCC: Module power supply – 5V
 GND: Ground
 SIG: PWM input signal
 Vin: Input voltage 5-24 V
 OUT: Module output for connecting to motor

Microprocessor Theory And Interfacing Lab Manual Page


Microprocessor Theory And Interfacing Lab Manual Page
Speed Control with L298N Motor Driver Module
This L298N Motor Driver Module is a high power motor driver module for driving DC and Stepper
Motors. This module consists of an L298 motor driver IC and a 78M05 5V regulator. L298N Module
can control up to 4 DC motors, or 2 DC motors with directional and speed control.

L298N Module Pinout Configuration

Pin Name Description

IN1 & IN2 Motor A input pins. Used to control the spinning direction of
Motor A

IN3 & IN4 Motor B input pins. Used to control the spinning direction of
Motor B

ENA Enables PWM signal for Motor A

ENB Enables PWM signal for Motor B

OUT1 & Output pins of Motor A


OUT2

OUT3 & Output pins of Motor B


OUT4

12V 12V input from DC power Source

Microprocessor Theory And Interfacing Lab Manual Page


5V Supplies power for the switching logic circuitry inside L298N IC

GND Ground pin

L298 Module Features & Specifications

 Driver Model: L298N 2A


 Driver Chip: Double H Bridge L298N
 Motor Supply Voltage (Maximum): 46V
 Motor Supply Current (Maximum): 2A
 Logic Voltage: 5V Driver Voltage: 5-35V Driver Current:2A
 Logical Current:0-36mA Maximum Power (W): 25W


 VCC pin supplies power for the motor. It can be anywhere between 5 to
35V. Remember, if the 5V-EN jumper is in place, you need to supply 2 extra
volts than motor’s actual voltage requirement, in order to get maximum
speed out of your motor.
 GND is a common ground pin.
 5V pin supplies power for the switching logic circuitry inside L298N IC. If
the 5V-EN jumper is in place, this pin acts as an output and can be used to
power up your Arduino. If the 5V-EN jumper is removed, you need to
connect it to the 5V pin on Arduino.
ENA pins are used to control speed of Motor A. Pulling this pin HIGH(Keeping the
jumper in place) will make the Motor A spin, pulling it LOW will make the

Microprocessor Theory And Interfacing Lab Manual Page


 motor stop. Removing the jumper and connecting this pin to PWM input
will let us control the speed of Motor A.
 IN1 & IN2 pins are used to control spinning direction of Motor A. When one
of them is HIGH and other is LOW, the Motor A will spin. If both the inputs
are either HIGH or LOW the Motor A will stop.
 IN3 & IN4 pins are used to control spinning direction of Motor B. When one
of them is HIGH and other is LOW, the Motor B will spin. If both the inputs
are either HIGH or LOW the Motor B will stop.
 ENB pins are used to control speed of Motor B. Pulling this pin
HIGH(Keeping the jumper in place) will make the Motor B spin, pulling it
LOW will make the motor stop. Removing the jumper and connecting
this pin to PWM input will let us control the speed of Motor B.
 OUT1 & OUT2 pins are connected to Motor A.
 OUT3 & OUT4 pins are connected to Motor B.


Cod
e

Microprocessor Theory And Interfacing Lab Manual Page


SERVO MOTOR
What is Servo?
Servo is a general term for a closed loop control system. A closed loop system
uses the feedback signal to adjust the speed and direction of the motor to
achieve the desired result.

Microprocessor Theory And Interfacing Lab Manual Page


RC servo motor works on the same principal. It contains a small DC motor
connected to the output shaft through the gears. The output shaft drives a
servo arm and is also connected to a potentiometer (pot).

The potentiometer provides position feedback to the servo control unit where the
current position of the motor is compared to the target position. According to the
error, the control unit corrects the actual position of the motor so that it matches
the target position.
How Servo Motors Work?
You can control the servo motor by sending a series of pulses to the signal
line. A conventional analog servo motor expects to receive a pulse roughly
every 20 milliseconds (i.e. signal should be 50Hz). The length of the pulse
determines the position of the servo motor.

 If the pulse is high for 1ms, then the servo angle will be zero.

Microprocessor Theory And Interfacing Lab Manual Page


 If the pulse is high for 1.5ms, then the servo will be at its center position.
 If the pulse is high for 2ms, then the servo will at 180 degrees.
 Pulses ranging between 1ms and 2ms will move the servo shaft through the
full 180 degrees of its travel.

The duration of the pulses may sometimes vary with different brands and they
can be 0.5ms for 0 degrees and 2.5ms for 180 degrees.

Servo Motor Pinout


Servo motors typically have three connections and are as follows:

GND is a common ground for both the motor and logic.


5V is a positive voltage that powers the servo.
Control is input for the control system.

The color of the wires varies between servo motors, but the red wire is always 5V
and GND will either be black or brown. The control wire is usually orange or
yellow.

Microprocessor Theory And Interfacing Lab Manual Page


Wiring Servo Motor to Arduino UNO
Let’s hook the servo motor up to the Arduino.
For example let’s use SG90 Micro Servo Motor. It runs on 4.8-6VDC (5V
Typical) and can rotate approximately 180 degrees (90 in each direction).
It consumes around 10mA at idle and 100mA to 250mA when moving, so we can
power it up through 5-volt output on the Arduino.
If you have a servo that consumes more than 250mA, consider using a
separate power supply for your servo.
Connect the Red wire to the 5V on Arduino (or DC jack) and Black/Brown wire to
ground. Finally connect the Orange/Yellow wire to the PWM enabled pin 9.

Microprocessor Theory And Interfacing Lab Manual Page


Controlling Servo with a Potentiometer
Our next step is to add a potentiometer so that we can control the position of the
servo by turning the knob.
Wiring
As the wiring diagram shows you’ll need a potentiometer, any value from 10k up
will be OK. Connect one end of the pot to ground, the other end to the Arduino
5V and the wiper to analog input A0.

Microprocessor Theory And Interfacing Lab Manual Page


Arduino Code
The code to make the servo follow the knob’s position is simpler than to make it
sweep.
#include <Servo.h>
int potPin = 0; int
servoPin = 9;
Servo servo;
void setup() {
servo.attach(servoPin)
;
}
void loop() {
int reading = analogRead(potPin);
int angle = map(reading, 0, 1023, 0, 180);
servo.write(angle);
}

Stepper motor
THEORY
A Stepper Motor or a step motor is a brushless, synchronous motor, which divides a full rotation
into a number of steps. Unlike a brushless DC motor, which rotates continuously when a fixed
DC voltage is applied to it, a step motor rotates in discrete step angles.
The Stepper Motors therefore are manufactured with steps per revolution of 12, 24, 72, 144, 180,
and 200, resulting in stepping angles of 30, 15, 5, 2.5, 2, and 1.8 degrees per step. The stepper
motor can be controlled with or without feedback.
imagine a printer. There are lots of moving parts inside a printer, including motors. One such
motor acts as the paper feed, spinning rollers that move the piece of paper as ink is being printed
on it. This motor needs to be able to move the paper an exact distance to be able to print the next
line of text or the next line of an image.

Stepper motor rotates in steps. To understand its principle, consider the logical diagram of its
construction given below. Two winding, A and B are the stator of motor. Permanent magnet
having North and South poles is rotor of the motor. The basic arrangement of stator and rotor in
stepper motor is shown in figure below.

Microprocessor Theory And Interfacing Lab Manual Page


Now if we energise winding B, it will create North and South poles on winding B as
shown in figure below which will attract opposite poles of magnet towards it. This
causes rotor (permanent magnet) to rotate by a step.

Now, similarly for winding A, if we energise winding A, then the unlike poles will be
attracted and make step as shown in figure below.

Microprocessor Theory And Interfacing Lab Manual Page


In this way, we can provide sequence of steps to create rotation.

Step Angle
Step angle is the minimum angle that stepper motor will cover within one move/step.
Number of steps required to complete one rotation depends upon step angle. E.g. If
step angle is of 45° then 8 steps are required to complete one rotation as shown in
figure below.

Depending upon stepper motor configuration, step angle varies e.g. 0.72°, 1.8°, 3.75°,
7.5°, 15° etc.

Stepper motors are classified depending upon construction and winding arrangement.

Microprocessor Theory And Interfacing Lab Manual Page


 Depending upon winding arrangement
- Unipolar Stepper Motor
- Bipolar Stepper Motor
 Depending upon construction
- Permanent Magnet Stepper Motor
- Variable Reluctance Stepper Motor
- Hybrid Stepper Motor
Unipolar Stepper Motor

 Unipolar Stepper Motor has centre tapped winding with 5 (If both centres are
connected
 internally) or 6 wires as shown in below figure.
 Generally, these centre tapped connections are connected to the power supply.
 By providing ground path to the winding leads we can allow the flow of current
through each half of coil which create magnetic poles. By altering poles
sequentially, we can rotate rotor accordingly.
 The current is unidirectional in unipolar motor.
 Due to centre tap, each winding is divided i.e. current flows through half of
winding.
 Due to its centre tap arrangement, we do not need to change current direction to
change magnetic pole on winding. Here we just need to alter ground connection
at winding ends.

Bipolar Stepper Motor

 Bipolar stepper Motor has no centre tap connection. Normally it is of two


windings i.e. 4 wire end as shown in below figure.

Microprocessor Theory And Interfacing Lab Manual Page


 Current flows through full winding of stator.
 The current is Bidirectional in Bipolar stepper motor i.e. we need to alter current
direction through winding to alter magnetic pole of that winding.

Difference between Unipolar and Bipolar Stepper Motor

 As per name, they already differ in current direction.


 Also, due to unidirectional arrangement, Unipolar Stepper Motor do not require to
control direction of current. So, it does not require H bridge like circuitry for
bidirectional operation. A simple ULN2003 driver circuitry is used to drive it.
 Whereas in Bipolar Stepper Motor, it requires H bridge driver circuitry e.g. like
L293D driver for bidirectional current control.
 Unipolar Stepper Motor has less torque than Bipolar Stepper Motor because in
unipolar stepper motor current flows through half of the winding; whereas in
bipolar stepper motor current flows through full winding.

Main difference between servo motor and Stepper motor


the control methods of stepper motors and servo motors are different. The stepper motor
controls the rotation angle by controlling the number of pulses. One pulse corresponds to one
step angle. However, because there is no feedback signal, the motor does not know where it is,
and the position accuracy is not high enough. The servo motor also controls the rotation angle by
controlling the number of pulses. Each time the servo motor rotates one angle, a corresponding
number of pulses will be sent out, and the drive will also receive the feedback signal, which is
compared with the pulse received by the servo motor. In this way, the system will know how

Microprocessor Theory And Interfacing Lab Manual Page


many pulses are sent to the servo motor and how many pulses are withdrawn at the same time. In
this way, the rotation of the motor can be controlled very accurately, thereby achieving precise
positioning. The accuracy can reach 0.001mm.
Why called them servo and stepper motor

A servo motor is a general term used for a specific kind of linear or rotary actuators.
Basically, the name servo motor is related to the term servomechanism, which means that the
motor is constantly monitored to control its motion.

Stepper motors are so named because each pulse of electricity turns the motor one step.
Stepper motors are controlled by a driver, which sends the pulses into the motor causing it to
turn.

Control Stepper Motor with L298N Motor Driver & Arduino


The 28-BYJ48 Stepper Motors are one of the most commonly used stepper motors. You
can find this or similar motors in your DVD drives, Motion camera and many more similar devices.
The motor has a 4 coil unipolar arrangement and each coil is rated for +5V hence it is relatively
easy to control with any basic microcontrollers.

28- BYJ48 Stepper Motor Pinout Configuration

No: Pin Name Wire Color Description

1 Coil 1 Orange This Motor has a total of four coils. One end of all the coils are
connect to +5V (red) wire and the other end of each coil is
pulled out as wire colors Orange, Pink, Yellow and Blue
respectively

2 Coil 2 Pink

3 Coil 3 Yellow

4 Coil 4 Blue

5 +5V Red We should supply +5V to this wire, this voltage will appear
across the coil that is grounded.

Microprocessor Theory And Interfacing Lab Manual Page


28BYJ-48 Stepper Motor Technical Specifications
 Rated Voltage: 5V DC
 Number of Phases: 4
 Stride Angle: 5.625°/64
 Pull in torque: 300 gf.cm
 Insulated Power: 600VAC/1mA/1s
 Coil: Unipolar 5 lead coil
Where to use 28-BYJ48 Stepper Motor
These kind of motors are commonly used in your DVD drives, Motion camera and other
similar applications. The motor has a 4 coil unipolar arrangement and each coil is rated
for +5V hence it is relatively easy to control with any basic microcontrollers. These
motors has a stride angle of 5.625°/64, this means that the motor will have to make 64
steps to complete one rotation and for every step it will cover a 5.625° hence the level of
control is also high. However, these motors run only on 5V and hence cannot provide
high torque, for high torque application you should consider the Nema17 motors. So
if you are looking for a compact easy to use stepper motor with decent torque then
this
motor is the right choice for you.
How to use 28-BYJ48 Stepper Motor
These stepper motors consume high current and hence a driver IC like the ULN2003 is
mandatory. To know how to make this motor rotate we should look into the coil diagram
below.

Microprocessor Theory And Interfacing Lab Manual Page


As we can see there are four coils in the motor and one end of all the coil is tied to +5V
(Red) and the other ends (Orange, Pink, Yellow and Blue) are taken out as wires. The
Red wire is always provided with a constant +5V supply and this +5V will be across
(energize) the coil only if the other end of the coil is grounded. A stepper motor can be
made to rotate only if the coils are energized (grounded) in a logical sequence. This
logical sequence can be programmed using a microcontroller or by designing a digital
circuit. The sequence in which each coil should be triggered is shown in the table
below. Here “1” represent the coil is held at +5V, since both the ends of coil is at +5V
(red and other end) the coil will not be energized. Similarly “0” represents the coil is
held to ground, now one end will be +5V and the other one is grounded so the coil will
be energized.

The 28BYJ-48 is a 5-wire unipolar stepper motor that runs on 5 volts.


The interesting thing about this motor is that people have been using it in countless
applications over the last few decades. It is used in air-conditioner, vending machines
and many other applications

Control 28BYJ-48 Stepper Motor with ULN2003 Driver


28BYJ-48 Gear Reduction Ratio
According to the data sheet, when the 28BYJ-48 motor runs in full step mode,
each step corresponds to a rotation of 11.25°. That means there are 32 steps
per revolution (360°/11.25° = 32).

Microprocessor Theory And Interfacing Lab Manual Page


In addition, the motor has a 1/64 reduction gear set. (Actually its 1/63.68395 but
for most purposes 1/64 is a good enough approximation)
What this means is that there are actually 32*63.68395 steps per revolution
= 2037.8864 ~ 2038 steps!
28BYJ-48 Power Consumption
The power consumption of the motor is around 240mA.
Because the motor draws too much power, it is best to power it directly from an
external 5V power supply rather than drawing that power from the Arduino.

The ULN2003 Driver Board


The motor usually comes with a ULN2003 based driver board.

Microprocessor Theory And Interfacing Lab Manual Page


The ULN2003 is one of the most common motor driver ICs, consisting of an
array of 7 Darlington transistor pairs, each pair is capable of driving loads of up
to 500mA and 50V. Four out of seven pairs are used on this board.

The board has a connector that mates the motor wires perfectly which makes it
very easy to connect the motor to the board. There are also connections for
four control inputs as well as power supply connections.

The board has four LEDs that show activity on the four control input lines (to
indicate stepping state). They provide a nice visual when stepping.
The board also comes with an ON/OFF jumper to isolate power to the stepper
Motor.

ULN2003 Stepper Driver Board Pinout


The pinouts of the ULN2003 stepper driver board are as follows:

Microprocessor Theory And Interfacing Lab Manual Page


IN1 – IN4 pins are used to drive the motor. Connect them to a digital output pins
on the Arduino.
GND is a common ground pin.
VDD pin supplies power for the motor. Connect it to an external 5V power supply.
Because the motor draws too much power, you should NEVER use the 5V power
from your Arduino to power this stepper motor.
Motor Connector This is where the motor plugs into. The connector is keyed, so it
only goes in one way.

Wiring 28BYJ-48 Stepper Motor and ULN2003 Driver to Arduino


Now that we know everything about the motor, we can begin hooking it up to our
Arduino!
Start by connecting the power supply up to the ULN2003 driver.
Note that it is possible to directly power the stepper motor from the Arduino.
However, this is not recommended; as the motor may induce electrical noise
onto its power supply lines and this could damage the Arduino.
So, use a separate 5V power supply to power your stepper motors.

Microprocessor Theory And Interfacing Lab Manual Page


Next connect the ground from that power supply to the arduino’s ground. This is
very important so that we establish the same voltage reference between the two.
Now connect the driver board’s IN1, IN2, IN3, IN4 to the Arduino digital pins 8, 9,
10, and 11 respectively.
Finally, hook the motor cable from the stepper motor up to the driver board.
When you’re done you should have something that looks similar to the
illustration shown below.

Arduino Code – Using Built-in Stepper Library

Microprocessor Theory And Interfacing Lab Manual Page


---------------------------------------------------------------------------------------------

Procedure:

Microprocessor Theory And Interfacing Lab Manual Page


Table: Fill table according to
your connection diagram
Sr. No FET Module Arduino PIN
1 VCC VCC
2 GND GND
3 SIG 3
4 OUT 1 VCC MOTOR 1 VCC
5 OUT 1 GND MOTOR 1 GND
6 OUT 2 VCC MOTOR 2 VCC
7 OUT 2` GND MOTOR 2 GND

PIN Connection
Table: Fill table according
to your Sr. No LM298 N Module Arduino PIN connection
diagram 1 VCC VCC
2 GND GND
3 5v 9
4 ENA 8
5 IN1 7
6 IN2 6
7 IN3 5
8 IN4 4
9 ENB 3
10 OUT1 VCC MOTOR 1 VCC
11 OUT 1 GND MOTOR 1 GND
12 OUT 2 VCC MOTOR 2 VCC
13 OUT GND 2 MOTOR 2 GND

PIN Connection
Table: Fill table Sr. Servo Motor Arduino PIN according to your
connection No diagram
1 VCC VCC
2 GND GND
3 Data 4

Microprocessor Theory And Interfacing Lab Manual Page


PIN
Sr. Stepper Motor Stepper Motor Arduino PIN
Connection Table:
No Module Fill table according to
1 A In1 8 your connection
2 B In2 9 diagram
3 C In3 10
4 D In4 11
5
6

CONCLUSION:
In this experiment we learn about motor speed control with the help of some modules interfacing with

Arduino. We control the speed of DC motor, Servo motor, Stepper motor.

INTERFACING OF MOTOR (SPEED CONTROLLING)


Activity Name 
WITH ARDUINO
Group No.  07
Student Roll No.  8034 8035 8036 8037
C P Domain +
No. L Taxonomy Criteria Awarded Score (out of 4 for each cell)
L O
O
Conduct experiments in
laboratory in order to
interpret experimental data
1 A2 and displays its conformance
with analyzed results of
circuits.
-
- - - - -
Total

Microprocessor Theory And Interfacing Lab Manual Page


Experiment # 10: Interfacing of temperature sensor/module with
Arduino

OBJECTIVE:
Implementation of Temperature sensor / module interface with Arduino display result on serial monitor.
Implementation of Temperature sensor / module interface with Arduino display result on LCD.

EQUIPMENT:
Arduino
Temperature Sensor Module
Connecting Leads
THEORY:
In this Arduino Experiment we will learn how to use the DHT11 or the DHT22 sensor for measuring temperature
and humidity with the Arduino board. Ok now let’s see how these sensors actually work. They consist of a
humidity sensing component, a NTC temperature sensor (or thermistor) and an IC on the back side of the
sensor.
DHT11 is a low-cost, small-sized & easy-to-operate embedded sensor, consists of 4 pins, used
to measure Temperature(0°C to 50°C with ±2°C accuracy) & Relative Humidity(20% to 80% with
±5% accuracy) and provides calibrated digital output.

 DHT11 has a Capacitive Sensor for measuring humidity & NTC Thermistor for
temperature sensing. (We will cover them in detail below)

Microprocessor Theory And Interfacing Lab Manual Page


 It comes in a single package comprising of 4 pins with 0.1″ spacing between them
and a special package can be provided according to user demand.
 DHT11 updates the output value once every 2 seconds.
 Small-size, low cost, precise & calibrated output, small-size and up to 20 meters
signal transmission stand it out from other sensors.
 DHT11 uses a single-wire serial interface for data processing.
 It calibrates the humidity using humidity coefficients, which are stored in the OTP
program memory of the built-in controller.
 Its operating voltage is 3V to 5.5V, so it works with both 3.3V and 5V
microcontroller systems.
 It has a sampling frequency of 1Hz, so it samples the data after every 1sec.
 DHT11 has a dimension of 27mm x 59mm x 13.5mm (1.05″ x 2.32″ x 0.53″), so its
very small and can easily be placed in autonomous embedded projects.
DHT 11 Working Principle
 Now, let’s understand the working principle of the DHT11 temperature & humidity
sensor.
 As we have discussed earlier, it has two sensors inside it, so let’s have a look at both
of them separately:
DHT11 Temperature Sensing: -
On the other hand, for measuring temperature these sensors use a NTC temperature sensor or a thermistor.
A thermistor is actually a variable resistor that changes its resistance with change of the temperature. These
sensors are made by sintering of semiconductive materials such as ceramics or polymers in order to provide
larger changes in the resistance with just small changes in temperature
The term “NTC” means “Negative Temperature Coefficient”, which means that the resistance decreases with
increase of the temperature.
 For temperature sensing, it has an NTC (Negative Temperature Coefficient)
temperature sensor(also called a thermistor) mounted on the surface inside the plastic
casing.
 NTC temperature sensors are variable resistive sensors, and their resistance decreases
with an increase in the surrounding temperature.
 Thermistors are designed with sintering of semiconductors materials, such as ceramic
or polymers and they provide a large change in resistor with a small change in
temperature.

Microprocessor Theory And Interfacing Lab Manual Page


 Here’s the graph showing the relation between temperature and resistance for the
DHT11 sensor:

DHT11 Humidity Measurement


For measuring humidity they use the humidity sensing component which has two electrodes with moisture
holding substrate between them. So as the humidity changes, the conductivity of the substrate changes or the
resistance between these electrodes’ changes. This change in resistance is measured and processed by
the IC which makes it ready to be read by a microcontroller.
 For Humidity Measurement, it uses a capacitive humidity sensor, which has two
electrodes and a substrate material in between.
 The substrate material is used for holding the moisture on its surface.
 As moisture content changes in our environment, they are get saturated on the substrate
material, which in turn changes the resistance between electrodes.
 This change in electrode resistivity is then calibrated using the humidity
coefficient(saved in OTP memory) and the final relative humidity value is released.
 Here’s the image showing the internal structure of DHT11 humidity sensor:

Microprocessor Theory And Interfacing Lab Manual Page


DHT11 Communication Protocol
 DHT11 sensor uses a single-wire, two-way Serial Protocol for communicating with
third-party peripherals normally microcontrollers.
 We call it single-wire because the communication is performed through a single pin.
 It’s two-way because DHT11 receives commands from the microcontroller and then
responses back required data.
 Data sent by the DHT11 sensor is 40bits and it sends Higher Data Bits first.
 Data contains both Integral and decimal values of temperature and relative humidity
along with a checksum value.

DHT11 Data Format


DHT11 sends the 40Bit serial data in the below format:
1. 8-Bit Humidity(Integral)

2. 8-Bit Humidity(Decimal)

3. 8-Bit Temperature(Integral)

4. 8-Bit Temperature(Decimal)

5. 8-Bit Checksum

If DHT11 is sending the correct data, then it must send an 8-Bit Checksum data at the
end.

Applications
Because of its small size, low cost and ability to sense two values, DHT11 has a wide range of
applications:
 DHT11 is used in Home Automation Projects to maintain constant atmospheric values by
controlling the appliances(i.e. AC, Fan etc.) based on the sensor’s readings.
 It is also used at weather stations for temperature & humidity sensing.
 It is also used in automatic climate control appliances.
 Environment monitoring devices also utilize this sensor.
 Garden Monitoring Systems also use DHT11 sensors.

Microprocessor Theory And Interfacing Lab Manual Page


.DHT11 & DHT22 Sensors Temperature and Humidity
The DHT22 is the more expensive version which obviously has better specifications. Its temperature measuring
range is from -40 to +125 degrees Celsius with +-0.5 degrees’ accuracy, while the DHT11 temperature range
is from 0 to 50 degrees Celsius with +-2 degrees accuracy. Also the DHT22 sensor has better humidity measuring
range, from 0 to 100% with 2-5%
accuracy, while the DHT11
humidity range is from 20 to 80%
with 5% accuracy.
There are two specification
where the DHT11 is better than
the DHT22. That’s the sampling
rate which for the DHT11 is 1Hz
or one reading every second,
while the DHT22 sampling rate is
0,5Hz or one reading every two
seconds and also the DHT11 has
smaller body size. The operating
voltage of both sensors is from 3
to 5 volts, while the max current
used when measuring is 2.5mA.

Pin layout:

Microprocessor Theory And Interfacing Lab Manual Page


Circuit Diagram:

DHT11

Microprocessor Theory And Interfacing Lab Manual Page


DHT22

Circuit Diagram: DHT11 MODULE

Circuit Diagram: DHT22 MODULE

Microprocessor Theory And Interfacing Lab Manual Page


Other Temperature sensor for knowledge purpose only:
LM35 Temperature sensor:

LM35 Temperature sensor waterproof module:

Microprocessor Theory And Interfacing Lab Manual Page


LM35 Temperature sensor:

Comparison of Different Temperature Sensor:

DHT22
Sensor DHT11 LM35 DS18B20
(AM2302)

Temperature Temperature
Measures Temperature Temperature
Humidity Humidity

Microprocessor Theory And Interfacing Lab Manual Page


Communication
One-wire One-wire Analog One-wire
protocol

Supply
3 to 5.5V DC 3 to 6V DC 4 to 30 V DC 3 to 5.5V DC
voltage

Temperature
0 to 50ºC -40 to 80ºC -55 to 150ºC -55 to 125ºC
range

+/- 2ºC (at 0 to +/- 0.5ºC (at -40 +/-0.5ºC (at +/-0.5ºC (at -10 to
Accuracy
50ºC) to 80ºC) 25ºC) 85ºC)

Adafruit DHT Adafruit DHT


Library Library
DallasTemperature
Support
analogRead()
(Arduino IDE) Adafruit Adafruit
OneWire
Unified Sensor Unified Sensor
Library Library

Coding:
#include "DHT.h"
#define DHTPIN 2 // Digital pin connected to the DHT sensor
// Uncomment whatever type you're using!
//#define DHTTYPE DHT11 // DHT 11
#define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321
//#define DHTTYPE DHT21 // DHT 21 (AM2301)
DHT dht(DHTPIN, DHTTYPE);
void setup()
{ Serial.begin(9600
); dht.begin();}
void loop() { delay(200);
float h = dht.readHumidity();
float t = dht.readTemperature();
float f = dht.readTemperature(true);
float hif = dht.computeHeatIndex(f, h);
float hic = dht.computeHeatIndex(t, h, false);

Serial.print(F("Humidity: "));
Serial.print(h);
Serial.print(F("% Temperature: "));
Serial.println(t);
}DHT Library:

Microprocessor Theory And Interfacing Lab Manual Page


PROCEDURE:

1. Construct /assemble circuit of according to the diagram.


2. Connect the Arduino board to your computer using the USB cable.
3. Select the board and serial port as outlined in earlier section.
4. Write code of required task.
5. Verify / compile code and upload / run the code button to send sketch to the
Arduino.

Microprocessor Theory And Interfacing Lab Manual Page


CONCLUSION:

In this experiment we learn that add library of DHT11, DHT22 temperature sensor in Arduino and proteus. Coding

in Arduino and create circuit in proteus. Add HEX file in proteus and check the value.

Interfacing of temperature sensor /module


Activity Name  with arduino

Group No.  07
Student Roll No.  8034 8035 8036 8037
C P Domain +
No. L Taxonomy Criteria Awarded Score (out of 4 for each cell)
L O
O
Conduct experiments in
laboratory in order to
interpret experimental data
1 A2 and displays its conformance
with analyzed results of
circuits.
-
- - - - -
Total

Microprocessor Theory And Interfacing Lab Manual Page


Experiment # 11: Interfacing of ultrasonic sensor / module with Arduino
OBJECTIVE:
Implementation of ULTRA SONIC SENSOR / module interface with Arduino display result on
serial monitor for measuring distance and controlling servo motor.
Implementation of ULTRA SONIC SENSOR / module interface with Arduino display result on
LCD for measuring distance and controlling servo motor.
EQUIPMENT:
Arduino
Ultra-Sonic Sensor /Module
Connecting Leads
THEORY:
HC-SR04 Hardware Overview
At its core, the HC-SR04 Ultrasonic distance sensor consists of two ultrasonic transducers. The
one acts as a transmitter which converts electrical signal into 40 KHz ultrasonic sound pulses. The
receiver listens for the transmitted pulses. If it receives them it produces an output pulse whose
width can be used to determine the distance the pulse travelled. As simple as pie!
The sensor is small, easy to use in any robotics project and offers excellent non-contact range
detection between 2 cm to 400 cm (that’s about an inch to 13 feet) with an accuracy of 3mm. Since
it operates on 5 volts, it can be hooked directly to an Arduino or any other 5V logic
microcontrollers.
Here are complete specifications:

Operating Voltage DC 5V

Operating Current 15mA

Operating Frequency 40KHz

Max Range 4m

Min Range 2cm

Ranging Accuracy 3mm

Measuring Angle 15 degree

Trigger Input Signal 10µS TTL pulse

Dimension 45 x 20 x 15mm

HC-SR04 Ultrasonic Sensor Pinout

Microprocessor Theory And Interfacing Lab Manual Page


VCC is the power supply for HC-SR04 Ultrasonic distance sensor which we connect the 5V pin on
the Arduino.
Trig (Trigger) pin is used to trigger the ultrasonic sound pulses.
Echo pin produces a pulse when the reflected signal is received. The length of the pulse is
proportional to the time it took for the transmitted signal to be detected.
GND should be connected to the ground of Arduino.

Microprocessor Theory And Interfacing Lab Manual Page


Distance Calculation:-

How Does HC-SR04 Ultrasonic Distance Sensor Work?


It all starts, when a pulse of at least 10 µS (10 microseconds) in duration is applied to the Trigger
pin. In response to that the sensor transmits a sonic burst of eight pulses at 40 KHz. This 8-pulse
pattern makes the “ultrasonic signature” from the device unique, allowing the receiver to
differentiate the transmitted pattern from the ambient ultrasonic noise.
The eight ultrasonic pulses travel through the air away from the transmitter. Meanwhile the Echo
pin goes HIGH to start forming the beginning of the echo-back signal.
In case, If those pulses are not reflected back then the Echo signal will timeout after 38 mS (38

Microprocessor Theory And Interfacing Lab Manual Page


milliseconds) and return low. Thus a 38 mS pulse indicates no obstruction within the range of the
sensor.

If those pulses are reflected back the Echo pin goes low as soon as the signal is received. This
produces a pulse whose width varies between 150 µS to 25 mS, depending upon the time it took for
the signal to be received.
Transmission

Reception

Microprocessor Theory And Interfacing Lab Manual Page


The width of the received pulse is then used to calculate the distance to the reflected object. This
can be worked out using simple distance-speed-time equation, we learned in High school. In case
you forgot, an easy way to remember the distance, speed and time equations is to put the letters
into a triangle.

Microprocessor Theory And Interfacing Lab Manual Page


Let’s take an example to make it clearer. Suppose we have an object in front of the sensor at
an unknown distance and we received a pulse of width 500 µS on the Echo pin. Now let’s
calculate how far the object from the sensor is. We will use the below equation.
Distance = Speed x Time
Here, we have the value of Time i.e. 500 µs and we know the speed. What speed do we have? The
speed of sound, of course! Its 340 m/s. We have to convert the speed of sound into cm/µs in order
to calculate the distance. A quick Google search for “speed of sound in centimeters per
microsecond” will say that it is 0.034 cm/µs. You could do the math, but searching it is easier.
Anyway, with that information, we can calculate the distance!
Distance = 0.034 cm/µs x 500 µs
But this is not done! Remember that the pulse indicates the time it took for the signal to be sent
out and reflected back so to get the distance so, you’ll need to divide your result in half.
Distance = (0.034 cm/µs x 500 µs) / 2
Distance = 8.5 cm
So, now we know that the object is 8.5 centimeters away from the sensor
Circuit Diagram:
Connecting the HC-SR04 to the Arduino is pretty easy. Start by placing the sensor on to your
breadboard. Connect VCC pin to the 5V pin on the Arduino and connect GND pin to the Ground
pin on the Arduino.

Microprocessor Theory And Interfacing Lab Manual Page


Coding:
#include <NewPing.h>
#include<LiquidCrystal.h>
#define TRIGGER_PIN 5 // Arduino pin tied to trigger pin on the ultrasonic sensor.
#define ECHO_PIN 4 // Arduino pin tied to echo pin on the ultrasonic sensor.
#define MAX_DISTANCE 200 // Maximum sensor distance is rated at 400-500cm.
NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and
maximum distance.
void setup()
{ Serial.begin(9600)
; lcd.begin(16, 2);}
void loop() {
delay(50); // Wait 50ms between pings
Serial.print("Ping: ");
Serial.print(sonar.ping_cm()); // Send ping, get distance in cm and print result (0 = outside set
distance range)
Serial.println("cm");
}

Ultrasonic Library:- (newPing Libraray)

Microprocessor Theory And Interfacing Lab Manual Page


PROCEDURE:
1. Construct /assemble circuit of required task.
2. Connect the Arduino board to your computer using the USB cable.
3. Select the board and serial port as outlined in earlier section.
4. Write code of required task.
5. Verify / compile code and upload / run the code button to send sketch to the Arduino.
6. Check the result of the required Task.
7. Save the result and attached with Report.

PIN Connection Table: Fill


table according to Sr. No Ultrasonic Sensor / Arduino PIN your circuit
diagram Module
1 Trigger 5
2 Echo 4
3
4

Microprocessor Theory And Interfacing Lab Manual Page


CONCLUSION:
In this experiment we learn that add library of ultrasonic sensor with the name of NewPing. Create coding define pins
and copy HEX file paste in proteus, run the circuit, check the readings.

Interfacing of ultrasonic sensor / module with


Activity Name  Arduino

Group No.  07
Student Roll No.  8034 8035 8036 8037
C P Domain +
No. L Taxonomy Criteria Awarded Score (out of 4 for each cell)
L O
O
Conduct experiments in
laboratory in order to
interpret experimental data
1 A2 and displays its conformance
with analyzed results of
circuits.
-
- - - - -
Total

Microprocessor Theory And Interfacing Lab Manual Page


Experiment # 12: Interfacing infrared sensor with Arduino (open ended lab)

OBJECTIVE:
To get familiar with Interfacing Infrared Sensor with Arduino
EQUIPMENT:
Arduino
Infrared Sensor
LED
LCD
Connection Wires.

WHAT IS OPEN ENDED LAB:


An open-ended lab is where students are given the freedom to develop their own experiments, instead of
merely following the already set guidelines from a lab manual or elsewhere.
Making labs open-ended pushes students to think for themselves and think harder. The students here have to
devise their own strategies and back them with explanations, theory and logical justification. This not only
encourages students to come up with their experiments, but requires them to defend themselves and their
experiment, if questioned.
THEORY:
This Experiment is based on the last experiment of Ultrasonic sensor. Working and connection is almost same
but the biggest difference between IR sensor vs. ultrasonic sensors is the way in which the sensor works.
Ultrasonic sensors use sound waves (echolocation) to measure how far away you are from an object. On the
other hand, IR sensors use Infrared light to determine whether or not an object is present.
Due to the open ended lab used the previous knowledge based on the previous experiment you have to
construct the circuit and code for required task given at the end.
Accuracy and reliability are also big differentiators in these sensors. Most often, ultrasonic sensors will provide
you more reliable and accurate data than IR sensors. If you want an accurate, numerical representation of
distance for your project, I’d almost always choose an Ultrasonic sensor.
An infrared sensor is an electronic module which is used to sense certain physical appearance of its surroundings
by either emitting and/or detecting infrared radiation. IR transmitter transmits IR signal, as that signal detects
any obstacle in its path, the transmitted IR signal reflects back from the obstacle and received by the receiver.
An infrared light emitting diode (IR LED) emits light of Infrared range 700 nanometers (nm) to 1 mm. This light is
not visible by naked eyes but can be seen by a camera (that is why these are also used in night vision cameras).
A photo diode gives response in term of change in resistance when light falls on it. That change is measured in
terms of voltage. Infrared (IR) Sensor Module is a distance proximity sensor “switch”. When there is an
object or obstacles that are close enough to block the view in front of 2 LEDs, it triggers the infrared trans-
receiver module. The clear LED is the IR emitter while the black LED is the IR receiver. It uses the
electromagnetic reflection principle where when the reflective surface (object) is closer, the receiver will receive
stronger signal from transmitter due to shorter distance traveled of reflected of wave.
When there is a object that is close enough, the IR electromagnetic detection received by the IR receiver is
higher than the threshold level (user pre-set level), the sensor will change the output switch mode so that
microprocessor board such as Arduino can execute what is going to do next. IR Sensor Module has only 1 main
output signal which is Digital Output. Digital Output either go high (5V or 3.3V depends on the input voltage) or
low (0V), thus this module cannot be used as a distance measurement but just as a trigger switch.
When there is no obstacles or object within the detection distance, the output is at HIGH position (5V or 3.3V).
When the distance shorter than or equal to the threshold set, the output signal will change to position LOW
(0V). The distance threshold can be set by adjusting the potentiometer / trimpot on the board. This sensor
module only able to detect distance between 2cm and 30cm within the view of the IR LED and Photoresistor.
The trigger distance is somehow very subjective to object’s surface material, color and shape. Practically I
would recommend this sensor switch for application less than 10cm distance. Thus this module is suitable for
very close range of detection such as obstacle avoidance and virtual touch switch application.
An IR LED and a Photo diode are used in a combination for proximity and color detection. An IR LED (transmitter)
emits IR light, that light gets reflected by the object, the reflected light is received by an IR receiver (Photo
Diode). Amount of reflection and reception varies with the distance. . This difference causes to change in input

Microprocessor Theory And Interfacing Lab Manual Page


voltage through IR input. This variation in input voltage is used for proximity detection.
For color detection application: The amount of reflected light depends upon the color of surface
from which it is reflected. The reflection is different for different colored surfaces. This makes it a
color detector.

PINOUT:
1. VCC: 3.3V-5V power input pin
2. GND: 0V power pin
3. OUT: Digital Output Pin

TECHNICAL SPECIFICATION/RATING
Operating Voltage: 3.0V – 6.0V
Current: at 3.3V : ~23 mA & at 5.0V: ~43 mA

CONNECTION DIAGRAM

Microprocessor Theory And Interfacing Lab Manual Page


Code
Write code according to each Task given at the end.
const int IRSensor = 2; // the number of the infrared sensor pin

void setup()

pinMode (IRSensor, INPUT); //initialize the infrared sensor sensor pin as an input:

pinMode (LED_BUILTIN, OUTPUT); //initialize the LED pin as an output:

Microprocessor Theory And Interfacing Lab Manual Page


}

void loop()

int sensorState = digitalRead (IRSensor); //read the state of the infrared sensor sensor value:

if (sensorState == HIGH) //If the infrared sensor does not detect any object or obstacle, then

sensorState is HIGH:

digitalWrite(LED_BUILTIN, LOW); //Turn LED OFF

else //If the infrared sensor detects any object or obstacle, then sensorState state is HIGH:

digitalWrite(LED_BUILTIN, HIGH); //Turn LED ON

PROCEDURE:
The connections for the IR sensor with the Arduino are as follows: Connect the Ground wire on
the IR sensor to GND. Connect the middle of the IR sensor which is the VCC to 5V on the
Arduino. Connect the signal pin on the IR sensor to pin 2 on the Arduino.

Microprocessor Theory And Interfacing Lab Manual Page


PIN Connection Table: Fill table according to your circuit diagram

Sr. No IR Sensor Pin Arduino PIN


1 out 2
2 Power (5V)
3 Ground
4 Test pin

CONCLUSION:

In this experiment we learn about inferred sensor its Arduino coding and circuit in proteus. First we copy Hex file, paste in
proteus and run the circuit. When we trigger test pin 1 the led will on

.
Interfacing infrared sensor with Arduino (open
Activity Name 
ended lab)
Group No.  7
Student Roll No.  8034 8035 8036 8037
C P Domain +
No. L Taxonomy Criteria Awarded Score (out of 4 for each cell)
L O
O
Able to follow the
procedure
according to
the given
1 4 5 P2 task
and
reproduce
the results
with some
parametric
changes in
the
provided task.

Total

Microprocessor Theory And Interfacing Lab Manual Page


Experiment # 13: Interfacing of voltage and current sensor / module with
Arduino

OBJECTIVE:
To get familiar with Interfacing of DC & AC Voltage sensor / module with Arduino.
To get familiar with Interfacing of DC & AC Current sensor / module with Arduino.
EQUIPMENT:
Arduino
DC Voltage Sensor, DC Current Sensor
AC Voltage Sensor, AC Current Sensor
Connection Wires.
THEORY:
DC Voltage Sensor
Measuring DC Voltage with a microcontroller (or any digital data device) requires the use of an Analog to Digital
Converter (ADC). Many modern microcontrollers, including the Arduino Uno, have a built-in ADC, making DC
voltage measurement the simplest of our four tasks.
Analog to Digital Converters
It’s a component that accepts an analog input and produces a digital output, the output being a digital
representation of the level of the input.

Voltage Dividers
The maximum input voltage that you can feed into an Arduino Uno ADC is 5-volts, with microcontrollers using
3.3-volt logic it is even less. Obviously, this is a bit impractical, as you’ll probably want to measure input
voltages exceeding that.

To accomplish this, we can use a voltage divider, a very simple circuit


constructed using two resistors. This reduces the voltage and has the added
benefit of increasing the input impedance.

Microprocessor Theory And Interfacing Lab Manual Page


You can certainly construct a voltage divider using discrete resistors, in fact, if you are planning to measure very
high voltages then you’ll probably have to.
I’ll be using one of these dividers in our experiments. It consists of a 7.5k resistor and a 30k resistor.
PINOUT
The Voltage Sensor is a simple module that can used with Arduino (or any other microcontroller with input
tolerance of 5V) to measure external voltages that are greater than its maximum acceptable value i.e. 5V in case
of Arduino.
Following is the image of the Voltage Sensor Module used in this project.

1. VCC: Positive terminal of the voltage to be measured (0-25V)


2. GND: Negative terminal of
the voltage to be measured
3. S: Analog Input of Arduino
4. +: Not connected (N/C)
5. –: GND of Arduino
Schematic of Voltage Sensor
Now, let us talk about the important thing
about the voltage sensor: its schematic. The

Microprocessor Theory And Interfacing Lab Manual Page


Voltage Sensor is basically a Voltage Divider consisting of two resistors with resistances of 30KΩ and 7.5KΩ i.e. a
5 to 1 voltage divider.
The following image shows the schematic of the Voltage Sensor Module with an input voltage limit of 25V.

Circuit Diagram

First, connect the “S” and “–” pins of the Voltage Sensor to A0 (Analog Input) and GND of Arduino respectively.
Then connect the external voltage pins (voltage to be measured) to the screw terminal (check for polarity).
Working
Since the Voltage Sensor module is basically a voltage divider circuit, you can calculate input voltage using the
formula
Vin = Vout * (R2/(R1+R2))
Here R1 = 30000, R2 = 7500 and Vout can be calculated from Analog Input of Arduino by using
Vout = (analogvalue * 5 / 1024).

Microprocessor Theory And Interfacing Lab Manual Page


Code

ACS-712 Current sensor Hardware Overview


The ACS712 Current Sensor is a product of Allegro Microsystems that can be used for precise measurement of
both AC and DC currents. This sensor is based on Hall Effect and the IC has an integrated Hall Effect device.
Coming to the output of the ACS712 Current Sensor, it produces an analog voltage that is proportional to AC or
DC currents (whichever is being sensed).
Pin Number Pin Name Pin Description
1&2 IP+ +ve terminals for sensing current

Microprocessor Theory And Interfacing Lab Manual Page


3&4 IP- -ve terminals for sensing current

5 GND Signal Ground

6 FILTER External Capacitor (to set the bandwidth)

7 VIOUT Analog Output

8 VCC Power Supply

IC OF ACS712

There are three variants of ACS712 Sensor based on the range of its current sensing. The optimized ranges are
+/-5A, +/-20A and +/-30A. depending on the variant, the output sensitivity also varies as follows:
ACS712 Model Optimized Current Range Output Sensitivity
ACS712 ELC-05 +/- 5A 185 mV/A
ACS712 ELC-20 +/- 20A 100 mV/A
ACS712 ELC-30 +/- 30A 66 mV/A
WORKING:
As mentioned earlier, the ASC712 is based on Hall Effect. There is a copper strip connecting the IP+ and IP- pins
internally. When some current flows through this copper conductor, a magnetic field is generated which is
sensed by the Hall Effect sensor.

Microprocessor Theory And Interfacing Lab Manual Page


The Hall Effect sensor then converts this magnetic field into appropriate voltage. In this method, the input and
the output are completely isolated.
ASC712 Current Sensor Application Circuit
The typical application circuit using the ASC712 Current Sensor is given in its datasheet and the following images
shows the same.

ACS712 Current Sensor Module


Using one of the variants of the ACS712 IC (5A, 20A or 30A), several manufacturers developed ASC712 Current
Sensor Module boards that can be easily interfaced to a microcontroller like Arduino.
The following image shows the ASC712 Current Sensor board used in this project.

Microprocessor Theory And Interfacing Lab Manual Page


As you can see, it is fairly a simple board with only a few components including the ASC712 IC, few passive
components and connectors.
This particular board consists of ASC712 ELC-30 i.e. the range of this board is +/- 30A. the following image shows
the components and pins on the board.

Interfacing ASC712 Current Sensor with Arduino


Measuring voltages (DC Voltages) with Arduino is very easy. If your requirement is to measure less than or equal
to 5V, then you can directly measure using the Arduino Analog Pins. If you need to measure more than 5V, then
you can use a simple voltage divider network or a voltage sensor module.
When it comes to measuring current, Arduino (or any other microcontroller) needs assistance from a dedicated
Current Sensor. So, Interfacing an ACS712 Current Sensor with Arduino helps us in measuring current with the
help of Arduino.
As ASC712 can be used for measuring either AC or DC currents, Arduino can be implemented to measure the
same.

Circuit diagram
Circuit Diagram of ASC712 Current Sensor with Arduino

Microprocessor Theory And Interfacing Lab Manual Page


Working
Make the connections and upload the code to Arduino. In the code, there is a small calculation for measuring
the current.
First, assuming the VCC to ASC712 is 5V, when there is no current flowing through the IP+ and IP- terminals, the
output voltage at VIOUT of ACS712 is 2.5V. This means that you need to subtract 2.5V from the voltage
measured at the analog pin.
Now, in order to calculate the current, divide this value with the sensitivity of the sensor (185mV/A for 5A
Sensor, 100mV/A for 20A Sensor and 66 mV/A for 30A Sensor).

OTHER ONE CODE FOR AC CURRENT With Library: If DC Replace AC with DC

Microprocessor Theory And Interfacing Lab Manual Page


AC VOLTAGE SENSOR / MODULE
THEORY
ZMPT101B, a voltage transformer ideal to measure the AC voltage. It has high accuracy, good consistency for
voltage and power measurement and it can measure up to 250V AC. It is simple to use and comes with a multi
turn trim potentiometer for adjusting the ADC output.
The ZMPT101B is a voltage transformer used to measure AC voltage. You can measure AC voltages up to 250
volts by using this module. The output of this sensor is analog. if you change input voltage, the output voltage
will change as well.
When there is no load on output (nothing is connected to input), the sensor has an initial voltage (Offset) of
VCC/2. That is, if nothing is connected to the input and the supply voltage of the module is 5 volts, the output of
the module will be 2.5 volts.

Microprocessor Theory And Interfacing Lab Manual Page


Specifications:
• Output Signal: Analog 0 - 5V
• Size: 49.5 (mm) x19.4 (mm)
• Operating temperature: 40C ~ + 70C
ZMPT101B module has 4 pins:
VCC: Module power supply: 5 V
GND: Ground
OUT: Module output which is analog.
Circuit Diagram

Microprocessor Theory And Interfacing Lab Manual Page


Working

Microprocessor Theory And Interfacing Lab Manual Page


Circuit Diagram for power calculation:

Microprocessor Theory And Interfacing Lab Manual Page


Code:

Microprocessor Theory And Interfacing Lab Manual Page


Procedure:
1. Construct /assemble circuit of required task.
2. Connect the Arduino board to your computer using the USB cable.
3. Select the board and serial port as outlined in earlier section.
4. Write code of required task.
5. Verify / compile code and upload / run the code button to send sketch to the Arduino.
6. Check the result of the required Task.
7. Save the result and attached with Report.

RESULT & CONCLUSION:

In this experiment we learn about the current and voltage measurement with current and voltage sensor
interfacing with Arduino.

Interfacing of voltage and current sensor / module


Activity Name 
with Arduino
Group No.  7
Student Roll No.  8034 8035 8036 8037
C P Domain +
No. L Taxonomy Criteria Awarded Score (out of 4 for each cell)
L O
O
Able to follow the
procedure
according to
the given
1 4 5 P2 task
and
reproduce
the results
with some
parametric
changes in
the
provided task.

Total

Microprocessor Theory And Interfacing Lab Manual Page


Experiment # 14: Interfacing of bluetooth module with arduino uno

OBJECTIVE:
Implementation of interfacing of Bluetooth module with Arduino.
EQUIPMENT:
Arduino
Bluetooth module (HC-05)
Connection Wires.
Android Application
THEORY:
HC-05 Bluetooth Module is an easy to use Bluetooth SPP (Serial Port Protocol) module, designed for
transparent wireless serial connection setup. Its communication is via serial communication which makes an
easy way to interface with controller or PC , Mobile.
HC-05 is a Bluetooth module which can communicate in two way. Which means, It is full-duplex. We can
use it with most micro controllers. Because it operates Serial Port Protocol (SSP). The module communicate with
the help of USART (Universal Synchronous/Asynchronous Receiver/Transmitter ) at the baud rate of 9600. and it
also support other baud rate. So we can interface this module with any microcontroller which supports USART.
The HC-05 can operate in two modes. One is Data mode and other is AT command mode. When the enable pin
is "LOW" the HC-05 is in Data Mode. If that pin set as "HIGH" the module is in AT command mode. Here we
operate this module in Data Mode.
Bluetooth protocol; an affordable communication method in PAN network, with a maximum data rate of 1Mb/S,
working in a nominal range of 100 meters using 2.4 G frequency is a common way of wireless communicating.
HC05 module is a Bluetooth module using serial communication, mostly used in electronics projects.
HC05 module has an internal 3.3v regulator and that is why you can connect it to 5v voltage. But we strongly
recommend 3.3V voltage, since the logic of HC05 serial communication pins is 3.3V. Supplying 5V to the module
can cause damage to the module. In order to prevent the module from damages and make it work properly, you
should use a resistance division circuit (5v to 3.3v ) between arduino TX pin and module RX pin. When master
and slave are connected, blue and red
LEDs on the board blink every 2seconds. If they aren’t connected, only blue one blinks every 2 seconds.
Specification:
 Model: HC-05,
 Architecture of these modules is based on the Cambridge Silicon Radio BC417,
 2.4 GHz Bluetooth Radio chip,
 +4dBm RF Transmit Power,
 48-bit unique device address (BD_ADDR),
 Chip uses an external 8 MB flash memory
 2Mb speed
 Communication Method: Serial Communication
 Operating Voltage: 4V to 6V (Typically +5V)
 Operating Current: 30mA

Microprocessor Theory And Interfacing Lab Manual Page


 Range: <100m
 Works with Serial communication (USART) and TTL compatible
 Can be easily interfaced with Laptop or Mobile phones with Bluetooth.

PINOUT
1. VCC: The operating voltage range is 3.3 volts. But I/O pins can withstand voltage of up to 5
volts. Therefore, we can connect 5 volts power source to this pin, and also other pins can also
operate on 5 volts signals such as Tx and Rx signals.
2. GND: Ground reference of both ESP8266 and HC-05 should be at the same level. Therefore,
we should connect a power supply, HC05, and ESP8266 ground pins to each other.
3. Tx: As discussed earlier, the HC-05 Bluetooth module uses UART communication to
transmit data. This is a transmitter pin. The TX pin will be the data transfer pin of
the module in UART.

Microprocessor Theory And Interfacing Lab Manual Page


4. Rx: This pin is a data receiving the pin in UART communication. It is used to receive
data from the microcontroller and transmits it through Bluetooth.
5. State: The state shows the current state of the Bluetooth. It gives feedback to the controller
about the connectivity of Bluetooth with another device. This pin has an internal
connection with the onboard LED which shows the working of HC05.
6. Enable/Key: Using an external signal, Enable/Key pin is used to change the HC-05 mode
between data mode and command mode. The HIGH logic input will transfer the device in
command mode and the LOW logic input will change the mode to data mode. By default, it
works in data mode.
7. Button: The command and data mode states are changeable through a button present on
the module.
8. LED: This pin shows the working status of module along with the State pin.
Bluetooth module interface with Arduino Uno
The circuit is so simple and small, there are only a few connections to be made
Arduino Pins Bluetooth Pins
RX (Pin 0) ———-> TX
TX (Pin 1) ———-> RX
5V ———-> VCC
GND ———-> GND
Connect a LED negative to GND of Arduino and positive to pin 13 with a resistance valued
between 220Ω – 1KΩ. And you're done with the circuit
Command and Function:
Serial.read();
Serial.readString()
;
Circuit Diagram

Microprocessor Theory And Interfacing Lab Manual Page


Note:
Don’t connect RX to RX and TX to
TX of Bluetooth to Arduino you will
receive no data, Here TX means
Transmit, and RX means Receive

Code
#define
: ledPin 13
int state = 0;
void setup()
{
pinMode(ledPin, OUTPUT);
digitalWrite(ledPin, LOW);
Serial.begin(9600);}

void loop() { if(Serial.available() > 0){ state =


Serial.read(); } if (state == '0') {
digitalWrite(ledPin, LOW); // Turn LED Off
state = 0;
}
else if (state == '1') {
digitalWrite(ledPin, HIGH); // Turn LED On
state = 0;
}
Microprocessor Theory And Interfacing Lab Manual Page
delay (50);
}

Android App:
After upload code in Arduino Download this mobile application from play store.

Configure Android Bluetooth:


If the Arduino is connected to the Bluetooth module correctly and is powered via the
PC/Laptop, then we should see the Bluetooth identity on the Android device. Firstly, turn ON
Bluetooth on the Android device Then scan and connect to the Arduino Bluetooth module.
Pair your device with HC 05/06 Bluetooth module Pair to HC 05/06 by entering default
password 1234 OR 0000.

Using The Kodular App To Control Arduino Once you have successfully paired your Android
device to the bluetooth module it’s now time to open the app. Click the bluetooth icon and
select your bluetooth module which should be displayed in the list.

Microprocessor Theory And Interfacing Lab Manual Page


Now app connect with Bluetooth module :

How Does It Work?


HC 05 works on serial communication. Here the android app is designed to send serial data
to the Bluetooth module when a certain button is pressed. The Bluetooth module at the other end
receives the data and sends it to Arduino through the TX pin of the Bluetooth module (RX pin of
Arduino). The Code fed to Arduino checks the received data and compares it. If received data is 1
the LED turns on turns OFF when received data is 0.
Open the serial monitor and watch the received data

Microprocessor Theory And Interfacing Lab Manual Page


Configuring the HC-05 Bluetooth Module – AT Commands
For this tutorial we need to configure both modules. In order to do that we need to switch to AT Command
Mode and here’s how we will do that. First we need connect the Bluetooth module to the Arduino as the
circuit schematics explained in the previous tutorials. What we need to do additionally is to connect the
“EN” pin of the Bluetooth module to 5 volts and also switch the TX and RX pins at the Arduino Board.

So the RX pin of the Arduino needs to be connected to the RX pin of the Bluetooth module, through the voltage
divider, and the TX pin of the Arduino to the TX pin of the Bluetooth module. Now while holding the small
button over the “EN” pin we need to power the module and that’s how we will enter the command mode. If the

Microprocessor Theory And Interfacing Lab Manual Page


Bluetooth module led is flashing every 2 seconds that means that we have successfully entered in the AT
command mode.
After this we need to upload an empty sketch to the Arduino but don’t forget to disconnect the RX and
TX lines while uploading. Then we need to run the Serial Monitor and there select “Both NL and CR”,
as well as, “38400 baud” rate which is the default baud rate of the Bluetooth module. Now we are ready
to send commands and their format is as following. All commands start with “AT”, followed by
the “+” sign, then a
<Parameter Name> and they end either with
the “?” sign which returns the current value
of the parameter or the “=” sign when we
want to enter a new value for that parameter.

Slave Configuration
So for example, if we type just “AT” which is a test
command we should get back the message “OK”.
Then if we type “AT+UART?” we should get back the
massage that shows the default baud rate which is 38400.
Then if we
type “AT+ROLE?” we will get back a massage
“+ROLE=0” which means that the Bluetooth device is in
slave mode. If we type “AT+ADDR?” we will get back
the address of the Bluetooth module and it should look
something like
this: 98d3:34:905d3f.
Now we need to write down this address as we will need it when configuring the master device.
Actually that’s all we need when configuring the slave device, to get its address, although we can change
many different parameters like its name, baud rate, pairing password and so on, but we won’t do that
for this example.

Master Configuration
Ok now let’s move on and configure the other Bluetooth module as a master device. First we will check
the baud rate to make sure it’s the same 38400 as the slave device. Then by typing “AT+ROLE=1” we will set
the Bluetooth module as a master device. After this using the “AT+CMODE=0” we will set the connect mode
to “fixed address” and using the “AT+BIND=” command we will set the address of the slave device that we
previously wrote down.

Microprocessor Theory And Interfacing Lab Manual Page


Note here that when writing the address we need to use commas instead of colons. Also note that we could
have skipped the previous step if we entered “1” instead of “0” at the “AT+CMODE” command, which
makes the master to connect to any device in its transmission range but that’s less secure configuration.
Here you can find a complete list of commands and parameters: HC-05 AT Commands List
Nevertheless, that’s all we need for a basic configuration of the Bluetooth modules to work as a
master and slave devices and now if we reconnect them in normal, data mode, and re-power the modules,
in a matter of seconds the master will connect to the slave. Both modules will start flashing every 2 seconds
indicating a successful connection.

Communication between Two HC-05 Bluetooth Module Examples


Ok so now we are ready make the practical example for this tutorial. Here’s the circuit schematics. We
will use a potentiometer, at the master, to control a servo motor at the slave. And vice versa, we will use a
push button, at the slave, to control a LED at the master.

Microprocessor Theory And Interfacing Lab Manual Page


Code:
Using Library SoftwareSerial.h
#include <SoftwareSerial.h>
SoftwareSerial BTSerial(5, 6); // RX | TX

void setup()
{
Serial.begin(9600);
Serial.println("Enter AT commands:");
BTSerial.begin(38400);// HC-05 default speed in AT command more
}
void loop()
{
if (BTSerial.available()) // read from HC-05 and send to Arduino Serial Monitor
Serial.write(BTSerial.read());
if (Serial.available()) // Keep reading from Arduino Serial Monitor and send to HC-05
BTSerial.write(Serial.read());
}
Changing Codes:
Open the serial monitor. Be sure that the baud rate are set to 9600 and Both NL & CR are selected.
If you send AT from serial monitor, OK will appear on the screen. Now you can change the name or password of
the module, check address, version
PROCEDURE:
1. Construct /assemble circuit of required task.
2. Connect the Arduino board to your computer using the USB cable.
3. Select the board and serial port as outlined in earlier section.
4. Write code of required task.
5. Verify / compile code and upload / run the code button to send sketch to the
Arduino.
6. Check the result of the required Task.
7. Save the result and attached with Report.

Fill table according to your circuit diagram

Microprocessor Theory And Interfacing Lab Manual Page


Sr. No Bluetooth Module Arduino PIN
1 TX RX PIN(0)

2 RX TX PIN(1)
3 GROUND

4 5V(SUPPLY)

5 EN

6 STATE

RESULTS & CONCLUSION:


In this experiment we learn about LED control with Bluetooth module with the help of LED
Bluetooth mobile app.

Activity Name  Interfacing of Bluetooth module with Arduino Uno.

Group No.  7
Student Roll No.  8034 8035 8036 8037
C P Domain +
No. L Taxonomy Criteria Awarded Score (out of 4 for each cell)
L O
O
Able to follow the
procedure
according to
the given
1 4 5 P2 task
and
reproduce
the results
with some
parametric
changes in
the
provided task.

Total

Microprocessor Theory And Interfacing Lab Manual Page


Microprocessor Theory And Interfacing Lab Manual Page

You might also like