Arduino Lab Manual
Arduino Lab Manual
COMMUNICATION ENGINEERING
LAB MANUAL
SEMESTER V
(2020- 2021)
1
DEPARTMENT OF ELECTRONICS AND COMMUNICATION
ENGINEERING
LABORATORY MANUAL
Course Team
Course Teacher(s)
June 2021
2
Course Learning Rationale (CLR):
Performance Criteria
The committee has decided that the following performance criteria (Key topics/questions) will be
used for evaluation of CLR and CLO pertaining to this course.
3
Program Educational Objectives
PEO1: Establish themselves as successful and creative practicing professional engineers both
nationally and globally in related fields of Electronics and Communication Engineering.
PEO2: Apply the acquired knowledge and skills in solving real-world engineering problems; develop
novel technology and design products, which are economically feasible and socially relevant.
PEO3: Develop an attitude of lifelong learning for sustained career advancement and adapt to the
changing multidisciplinary profession.
PEO4: Demonstrate leadership qualities, effective communication skills, and to work in a team of
enterprising people in a multidisciplinary and multicultural environment with strong adherence to
professional ethics.
PROGRAM
18ECO108J - Embedded
PROGRAM LEARNING OUTCOMES STUDENT
System Design Using ARDUINO OUTCOMES
S.NO COURSE LEARNING OUTCOMES 1 2 3 4 5 6 7 8 9 10 11 12 1 2 3
1 Analyze the programming skill. H - - - - - - - - - - - - H H
Apply the real time data’s into
2 H H H H H - - - H - H - - H H
digital
Interact with almost many devices H
3 - H H H - - - H - H - H H -
Learn techniques to handle timer
4 H H H H - - - H - H - H H -
delays and IO devices H
Use and modifying the existing
5 H - H H H - - - H - H - H H -
libraries
.
Session Plan
Contact
S. No. Description of Topic References
hours
Unit-I 6
1. [2]
Introduction to Arduino platform, Block diagram, 1
2. AT mega 328p architecture 1 [2]
3. Pin function, Overview of main features-I/O ports 1 [2]
4
Features-timers, interrupts 1 [2]
5. Features-PWM, SERIAL PORT, ADC 1 [2]
6. Introduction to Arduino IDE, Writing, saving, [2]
1
compiling with IDE.
Unit-II: 6
7. [4] chapters 1, 3
Introduction To Arduino C, Arduino C Data Types 1
8. [4] chapter 4
Decision Making in C 1
9. [4] chapters 5, 6
Program Loops in C, Functions in C 1
10. [4] chapter 8
Introduction to Pointers 1
11. Using Pointers Effectively, Structures, Unions, and [4] chapters 9, 10
1
Data Storage
12. [4] chapter 12
Arduino Libraries 1
Unit-III: 6
13. Analog And Serial Communication, Introduction To [2]
1
Analog Communication
14. Pulse Width Modulation, RS232 1 [2]
15. I2C 2 [2]
16. SPI Protocol 1 [2]
17. Interfacing with sensors 1 [2]
Unit-IV: 6
18. IO Programming, Introduction To Timer/Counters 2 [1], [3]
19. [1], [3]
Timer programming 2
5
Sl.No Contac Referenc
Description of experiments
. t hours e
1. Getting Started With Adriano 2 5
2. GPIO LED 2 5
3. Display Interface-7 Segment 2 5
4. Serial Communication 2 5
5. Sensor Interfacing For Temperature Monitoring 2 5
6. Sensor Interfacing For Displacement Measurement 2 5
7. DC Motor 2 5
8. PWM Based Servo Motor Interfacing 2 5
9. I2C Communication 2 5
10. Interrupt Programming 2 5
11. Repeat/Revision Of Experiments 2 5
Actuators – Stepper Motor, Watch Dog Timer (Study 2 5
12.
experiments)
13. Construct mini project work 6
Total contact hours 30
References
1. Michael-Margolis,Arduino-Cookbook., Revised edition, O’Reilly,1st edition, 2011
2. D.Dale.Wheat, Arduino.Internals, TIA publication, 5th edition, 2011
3. James M. Fiore, Embedded Controllers Using C and Arduino, ARDUINO open source
community, 2018
4. Jack Purdum ,Beginning C for Arduino , Apress, 2012
Assessment Methods
6
PREFACE
The content of this course consists of two parts, ‘simulation’ and ‘hardwired’. Computer simulation is
stressed upon as it is a key analysis tool of engineering design. “Arduino IDE” and “Tinkercad”
software is used for simulation of experiments
Students will carry out design experiments as a part of the experiments list provided in this lab
manual. Students will be given a specific design problem, which after completion they will verify
using the simulation software or hardwired implementation.
7
SRM INSTITUTE OF SCIENCE AND TECHNOLOGY
Faculty of Engineering and Technology
Department of Electronics and Communication Engineering
Sub Code : 18ECO108J Semester : V
Sub Title : EMBEDDED SYSTEM DESIGN USING ARDUINO Lab Course Time: June-Dec ‘20
Pre- requisite : NIL
Co- requisite : NIL
PROGRAM LEARNING OUTCOMES
PLO 1: Engineering Knowledge
Experiment 1: Getting Started With ARDUINO
Experiment 2: GPIO LED
Experiment 3: Display Interface-7 Segment
Experiment 4: Serial Communication
Experiment 5: Sensor Interfacing For Temperature Monitoring
Experiment 6: Sensor Interfacing For Displacement Measurement
Experiment 7: DC Motor
Experiment 8: PWM Based Servo Motor Interfacing
Experiment 9: I2C Communication
Experiment 10: Interrupt Programming
9
SRM INSTITUTE OF SCIENCE AND TECHNOLOGY
Faculty of Engineering and Technology
Department of Electronics and Communication Engineering
Sub Code: 18ECO108J Semester : V
Sub Title: EMBEDDED SYSTEM DESIGN USING ARDUINO Lab Course Time: June-Dec ‘20
Pre- requisite : NIL
Co- requisite : NIL
PLO5:Modern Tool
usage X X X X
10
SRM INSTITUTE OF SCIENCE AND TECHNOLOGY
Faculty of Engineering and Technology
Department of Electronics and Communication Engineering
Sub Code: 18ECO108J Semester : V
Sub Title: EMBEDDED SYSTEM DESIGN USING ARDUINO Lab Course Time: June-Dec ‘20
Pre- requisite : NIL
Co- requisite : NIL
11
SRM INSTITUTE OF SCIENCE AND TECHNOLOGY
Faculty of Engineering and Technology
Department of Electronics and Communication Engineering
Sub Code: 18ECC205J Semester : V
Sub Title: EMBEDDED SYSTEM DESIGN USING ARDUINO Lab Course Time: June-Dec ‘20
Pre- requisite : NIL
Co- requisite : NIL
MAPPING OF COURSE LEARNING OUTCOMES WITH EXPERIMENTS:
12
LABORATORY ORIENTATION
I. OVERALL PURPOSE
The laboratory portion of this course is designed to give the student practical experience in working
with ARDUINO. The laboratory integrate the theory taught in the lectures with practical design, and
should help the student to apply his or her knowledge of ARDUINO.
Every week before lab, each student should read over the laboratory design or experiment and work
out the various calculations, etc. that are outlined. The student should refer to the text as prescribed in
the course description for the fundamental theory.
Your grade will reflect how well you have prepared for the lab.
It is the responsibility of not only the laboratory staff, but also the students. A concerted effort to keep
the equipment in excellent condition and the working environment well-organized will result in a
productive and safe laboratory. There are useful guides one should follow to avoid the pitfalls in
measurement. Above all, keep in mind that safety is first!
Each student should maintain a laboratory notebook according to the following guidelines:
13
V. PRE-LAB WORK
There are pre-lab works for each experiment. The pre work must be completed in the logbook before
entering the laboratory. The pre-lab work usually consists of some questions that is closely related to
the experimental work and is intended to prepare you for the lab. The labs are designed so that a
student who has done the pre-lab work should be able to complete the lab in the allotted time. If you
find that you are having difficulties completing labs then it is probably a good idea for you to do all of
the theoretical work (in addition to the assigned pre work) for the experiment before entering the lab.
To ensure that you can complete the experimental tasks within the allocated lab session, you could
collect all the parts and components from the Lab stores and build the circuits on breadboards before
starting the actual lab. Therefore you have more time on testing in the lab session.
Lab reports will be submitted by each student at the beginning of the following lab period. The report
will be graded on clarity, legibility, and content, neither on length nor on the quality of the artwork.
Although the data is measured jointly, the text and analysis of the report must be original work and
may not be copied.
14
LABORATORY POLICIES AND REPORT FORMAT:
TITLE PAGE:
EXPERIMENT #
EXPERIMENT NAME
DATE
REPORT CONTENT:
III. DESIGN
IV. EXPERIMENT
V. POSTLAB QUESTIONS
- answer all the questions in the post lab component available at the end of each experiment in the
laboratory manual.
- the post lab questions are closely related to the experimental work you had done in the lab.
VI. SUMMARY
15
Be responsible for equipment and laboratory maintenance. For example:
16
10. Make sure to have low impedance ground connections between the test instruments and your
“breadboard”. Avoid ground loops!
The list could go on much longer. It represents the pitfalls of doing electronics in the real world.
To be responsible for your own safety and keep the laboratory in a good order, you must comply with
the rules below.
Solid footwear must be worn by all students inside the laboratory. Staffs are required by the
university to ensure that everyone in the laboratory is wearing solid footwear. Students with bare feet,
thongs, sandals, or other forms of open footwear will not be allowed into the laboratory.
No smoking, drinking, or eating is permitted in the laboratory (this includes chewing gum and
confectionaries).
Always have your circuits checked by a demonstrator before switching on, and always switch
the power off immediately after taking measurements.
Act sensibly and tidy up after yourself.
There is a safety switch on each bench which switches power to (and protects) the GPO's
(general purpose outlets/power points).
Under no circumstances should you attempt to remove any of the panels on the bench. There is
a 220 volt supply behind them which could be lethal.
You should not take equipment from another bench. If something is faulty (or missing) ask the
lab staff for assistance.
17
SAFETY
Safety in the electrical laboratory, as everywhere else, is a matter of the knowledge of potential
hazards, following safety precautions, and common sense. Observing safety precautions are important
due to pronounced hazards in any electrical/computer engineering laboratory. Death is usually certain
when 0.1 ampere or more flows through the head or upper thorax and have been fatal to persons with
coronary conditions. The current depends on body resistance, the resistance between body and ground,
and the voltage source. If the skin is wet, the heart is weak, the body contact with ground is large and
direct, then 40 volts could be fatal. Therefore, never take a chance on "low" voltage. When working in
a laboratory, injuries such as burns, broken bones, sprains, or damage to eyes are possible and
precautions must be taken to avoid these as well as the much less common fatal electrical shock. Make
sure that you have handy emergency phone numbers to call for assistance if necessary. If any safety
questions arise, consult the lab demonstrator or technical assistant/technician for guidance and
instructions. Observing proper safety precautions is important when working in the laboratory to
prevent harm to yourself or others. The most common hazard is the electric shock which can be fatal if
one is not careful.
ELECTRIC SHOCK
Shock is caused by passing an electric current through the human body. The severity depends mainly
on the amount of current and is less function of the applied voltage. The threshold of electric shock is
about 1 mA which usually gives an unpleasant tingling. For currents above 10 mA, severe muscle pain
occurs and the victim can't let go of the conductor due to muscle spasm. Current between 100 mA and
200 mA (50 Hz AC) causes ventricular fibrillation of the heart and is most likely to be lethal. What is
the voltage required for a fatal current to flow? This depends on the skin resistance. Wet skin can have
a resistance as low as 150 Ohm and dry skin may have a resistance of 15 kOhm. Arms and legs have a
resistance of about 100 Ohm and the trunk 200 Ohm. This implies that 240 V can cause about 500 mA
to flow in the body if the skin is wet and thus be fatal. In addition skin resistance falls quickly at the
point of contact, so it is important to break the contact as quickly as possible to prevent the current
from rising to lethal levels.
18
EQUIPMENT GROUNDING
Grounding is very important. Improper grounding can be the source of errors, noise and a lot of
trouble. Here we will focus on equipment grounding as a protection against electrical shocks. Electric
instruments and appliances have equipments casings that are electrically insulated from the wires that
carry the power. The isolation is provided by the insulation of the wires. However, if the wire
insulation gets damaged and makes contact to the casing, the casing will be at the high voltage
supplied by the wires. If the user touches the instrument he or she will feel the high voltage. If, while
standing on a wet floor, a user simultaneously comes in contact with the instrument case and a pipe or
faucet connected to ground, a sizable current can flow through him or her. However, if the case is
connected to the ground by use of a third (ground) wire; the current will flow from the hot wire
directly to the ground and bypass the user.
Equipment with a three wire cord is thus much safer to use. The ground wire (3rd wire) which is
connected to metal case is also connected to the earth ground (usually a pipe or bar in the ground)
through the wall plug outlet.
Always observe the following safety precautions when working in the laboratory:
1. Do not work alone while working with high voltages or on energized electrical equipment or
electrically operated machinery like a drill.
1. Power must be switched off whenever an experiment or project is being assembled, disassembled,
or modified. Discharge any high voltage points to grounds with a well-insulated jumper.
2. Remember that capacitors can store dangerous quantities of energy.
3. Make measurements on live circuits or discharge capacitors with well insulated probes keeping
one hand behind your back or in your pocket. Do not allow any part of your body to contact any
part of the circuit or equipment connected to the circuit.
4. After switching power off, discharge any capacitors that were in the circuit. Do not trust
supposedly discharged capacitors. Certain types of capacitors can build up a residual charge after
being discharged. Use a shorting bar across the capacitor, and keep it connected until ready for use.
If you use electrolytic capacitors, do not:
put excessive voltage across them
put ac across them
connect them in reverse polarity
1. Take extreme care when using tools that can cause short circuits if accidental contact is made to
other circuit elements. Only tools with insulated handles should be used.
19
5. If a person comes in contact with a high voltage, immediately shut off power. Do not attempt to
remove a person in contact with a high voltage unless you are insulated from them. If the victim is
not breathing, apply CPR immediately continuing until he/she is revived, and have someone dial
emergency numbers for assistance.
6. Check wire current carrying capacity if you will be using high currents. Also make sure your leads
are rated to withstand the voltages you are using. This includes instrument leads.
7. Avoid simultaneous touching of any metal chassis used as an enclosure for your circuits and any
pipes in the laboratory that may make contact with the earth, such as a water pipe. Use a floating
voltmeter to measure the voltage from ground to the chassis to see if a hazardous potential
difference exists.
8. Make sure that the lab instruments are at ground potential by using the ground terminal supplied
on the instrument. Never handle wet, damp, or ungrounded electrical equipment.
9. Never touch electrical equipment while standing on a damp or metal floor.
10. Wearing a ring or watch can be hazardous in an electrical lab since such items make good
electrodes for the human body.
11. When using rotating machinery, place neckties or necklaces inside your shirt or, better yet, remove
them.
12. Never open field circuits of D-C motors because the resulting dangerously high speeds may cause
a "mechanical explosion".
13. Keep your eyes away from arcing points. High intensity arcs may seriously impair your vision or a
shower of molten copper may cause permanent eye injury.
14. Never operate the black circuit breakers on the main and branch circuit panels.
15. In an emergency all power in the laboratory can be switched off by depressing the large red button
on the main breaker panel. Locate it. It is to be used for emergencies only.
16. Chairs and stools should be kept under benches when not in use. Sit upright on chairs or stools
keeping the feet on the floor. Be alert for wet floors near the stools.
17. Horseplay, running, or practical jokes must not occur in the laboratory.
18. Never use water on an electrical fire. If possible switch power off, then use CO2 or a dry type fire
extinguisher. Locate extinguishers and read operating instructions before an emergency occurs.
19. Never plunge for a falling part of a live circuit such as leads or measuring equipment.
20. Never touch even one wire of a circuit; it may be hot.
20
21. Avoid heat dissipating surfaces of high wattage resistors and loads because they can cause severe
burns.
22. Keep clear of rotating machinery.
PRECAUTIONARY STEPS BEFORE STARTING AN EXPERIMENT SO AS NOT TO WASTE TIME
ALLOCATED
a) Read materials related to experiment beforehand as preparation for pre-lab quiz and experimental
calculation.
b) Make sure that apparatus to be used are in good condition. Seek help from technicians or the lab
demonstrator in charge should any problem arises.
Power supply is working properly ieImax (maximum current) LED indicator is disable. Maximum
current will retard the dial movement and eventually damage the equipment. Two factors that will
light up the LED indicator are short circuit and insufficient supply of current by the equipment
itself. To monitor and maintain a constant power supply, the equipment must be connected to
circuit during voltage measurement. DMM are not to be used simultaneously with oscilloscope to
avert wrong results.
Digital millimetre (DMM) with low battery indicated is not to be used. By proper connection,
check fuses functionality (especially important for current measurement). Comprehend the use of
DMM for various functions. Verify measurements obtained with theoretical values calculated as
it is quite often where 2 decimal point reading and 3 decimal point reading are very much
deviated.
The functionality of voltage waveform generators are to be understood. Make sure that
frequency desired is displayed by selecting appropriate multiplier knob. Improper settings (i.e.
selected knob is not set at minimum (in direction of CAL – calibrate) at the bottom of knob)
might result in misleading values and hence incorrect results. Avoid connecting oscilloscope
together with DMM as this will lead to erroneous result.
Make sure both analog and digital oscilloscopes are properly calibrated by positioning sweep
variables for VOLT / DIV in direction of CAL. Calibration can also be achieved by standalone
operation where coaxial cable connects CH1 to bottom left hand terminal of oscilloscope. This
procedure also verifies coaxial cable continuity.
c) Internal circuitry configuration of breadboard or Vero board should be at students’ fingertips (i.e.
holes are connected horizontally not vertically for the main part with engravings disconnecting in-
line holes).
21
d) Students should be rest assured that measured values (theoretical values) of discrete components
retrieved i.e. resistor, capacitor and inductor are in accordance the required ones.
e) Continuity check of connecter or wire using DMM should be performed prior to proceeding an
experiment. Minimize wires usage to avert mistakes.
Name :
Register No. :
Day / Session :
Venue :
Title of Experiment :
Date of Conduction :
Date of Submission :
REPORT VERIFICATION
22
Date :
Staff Name :
Signature :
TABLE OF CONTENTS
23
Exp. 1: Getting Started With ARDUINO
Aim:
To blink the on-board LED with 75% Duty cycle and total time period of 1000ms.
Components Requirement:
Theory:
Code Structure
void setup() {
// put your setup code here, to run once:
pinMode(13, OUTPUT);
24
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(13, HIGH);
digitalWrite(13, LOW);
setup: It is called only when the Arduino is powered on or reset. It is used to initialize
variables and pin modes
loop: The loop functions runs continuously till the device is powered off. The main logic of
the code goes here. Similar to while (1) for micro-controller programming.
PinMode
Lab Procedure:
1. Connect the Arduino Uno Development Board to the Desktop/Laptop through Type B USB cable.
2. Write the code and compile it in Arduino IDE.
3. Select USB port in Arduino IDE.
4. Select Arduino Uno Development Board in Arduino IDE.
5. Download the code into Arduino Uno Development Board
6. Run the code in Arduino Uno Development Board.
7. Observe and verify the output.
Output:
Result:
25
Exp. 2: GPIO LED
Aim:
To control the brightness of the LED which is connected in any of the PWM pin.
Components Requirement:
Theory:
Led blinking is the most beginner & easy step to start your experiment with Arduino. Let’s get started.
Firstly, identify anode(+ve) & cathode (-ve) leg of LED. Following diagram gives a clear idea of LED.
A LED is connected to the GPIO pin 9 through a ballast resister to limit the current through the
LED.
26
Code Structure
void setup() {
// put your setup code here, to run once:
void loop() {
// put your main code here, to run repeatedly:
setup: It is called only when the Arduino is powered on or reset. It is used to initialize
variables and pin modes
loop: The loop functions runs continuously till the device is powered off. The main logic of
the code goes here. Similar to while (1) for micro-controller programming.
PinMode
Lab Procedure:
1. Connect the Arduino Uno Development Board to the Desktop/Laptop through Type B USB
cable.
2. Write the code and compile it in Arduino IDE.
3. Select USB port in Arduino IDE.
4. Select Arduino Uno Development Board in Arduino IDE.
5. Download the code into Arduino Uno Development Board
6. Run the code in Arduino Uno Development Board.
7. Observe and verify the output.
Output:
Code
/*
Fade
This example shows how to fade an LED on pin 9
using the analogWrite() function.
int brightness = 0;
void setup()
{
pinMode(9, OUTPUT);
}
void loop()
{
for (brightness = 0; brightness <= 255; brightness += 5) {
analogWrite(9, brightness);
delay(30); // Wait for 30 millisecond(s)
}
for (brightness = 255; brightness >= 0; brightness -= 5) {
analogWrite(9, brightness);
delay(30); // Wait for 30 millisecond(s)
}}
Result:
28
Exp. 3: DISPLAY INTERFACE-7 SEGMENT
Aim:
To display 7-segment LED
Components Requirement:
Theory:
A seven segment display got its name from the very fact that it got seven illuminating
segments. Each of these segments has a LED (Light Emitting Diode), hence the lighting. The
LEDs are so fabricated that lighting of each LED is contained to its own segment. The
important thing to notice here that the LEDs in any seven segment display are arranged in
common anode mode (common positive) or common cathode mode (common negative).
29
Code Structure
void setup() {
// put your setup code here, to run once:
void loop() {
// put your main code here, to run repeatedly:
Lab Procedure:
30
1. Connect the Arduino Uno Development Board to the Desktop/Laptop through Type B USB
cable.
2. Make the circuit connection accordingly.
3. Write the code and compile it in Arduino IDE.
4. Select USB port in Arduino IDE.
5. Select Arduino Uno Development Board in Arduino IDE.
6. Download the code into Arduino Uno Development Board
7. Run the code in Arduino Uno Development Board.
8. Observe and verify the output.
Output:
Code.
#define segA 6//connecting segment A to PIN6
#define segB 7// connecting segment B to PIN7
#define segC 8// connecting segment C to PIN8
#define segD 9// connecting segment D to PIN9
#define segE 10// connecting segment E to PIN10
#define segF 11// connecting segment F to PIN11
#define segG 12// connecting segment F to PIN12
{
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
pinMode(12, OUTPUT);
31
void loop()
switch (COUNT)
{
case 0://when count value is zero show”0” on disp
digitalWrite(segA, HIGH);
digitalWrite(segB, HIGH);
digitalWrite(segC, HIGH);
digitalWrite(segD, HIGH);
digitalWrite(segE, HIGH);
digitalWrite(segF, HIGH);
digitalWrite(segG, LOW);
break;
digitalWrite(segA, LOW);
digitalWrite(segB, HIGH);
digitalWrite(segC, HIGH);
digitalWrite(segD, LOW);
digitalWrite(segE, LOW);
digitalWrite(segF, LOW);
digitalWrite(segG, LOW);
break;
digitalWrite(segA, HIGH);
digitalWrite(segB, HIGH);
digitalWrite(segC, LOW);
digitalWrite(segD, HIGH);
digitalWrite(segE, HIGH);
digitalWrite(segF, LOW);
digitalWrite(segG, HIGH);
break;
digitalWrite(segA, HIGH);
digitalWrite(segB, HIGH);
digitalWrite(segC, HIGH);
digitalWrite(segD, HIGH);
digitalWrite(segE, LOW);
digitalWrite(segF, LOW);
digitalWrite(segG, HIGH);
32
break;
digitalWrite(segA, LOW);
digitalWrite(segB, HIGH);
digitalWrite(segC, HIGH);
digitalWrite(segD, LOW);
digitalWrite(segE, LOW);
digitalWrite(segF, HIGH);
digitalWrite(segG, HIGH);
break;
digitalWrite(segA, HIGH);
digitalWrite(segB, LOW);
digitalWrite(segC, HIGH);
digitalWrite(segD, HIGH);
digitalWrite(segE, LOW);
digitalWrite(segF, HIGH);
digitalWrite(segG, HIGH);
break;
digitalWrite(segA, HIGH);
digitalWrite(segB, LOW);
digitalWrite(segC, HIGH);
digitalWrite(segD, HIGH);
digitalWrite(segE, HIGH);
digitalWrite(segF, HIGH);
digitalWrite(segG, HIGH);
break;
digitalWrite(segA, HIGH);
digitalWrite(segB, HIGH);
digitalWrite(segC, HIGH);
digitalWrite(segD, LOW);
digitalWrite(segE, LOW);
digitalWrite(segF, LOW);
digitalWrite(segG, LOW);
break;
33
case 8:// when count value is 8 show”8” on disp
digitalWrite(segA, HIGH);
digitalWrite(segB, HIGH);
digitalWrite(segC, HIGH);
digitalWrite(segD, HIGH);
digitalWrite(segE, HIGH);
digitalWrite(segF, HIGH);
digitalWrite(segG, HIGH);
break;
digitalWrite(segA, HIGH);
digitalWrite(segB, HIGH);
digitalWrite(segC, HIGH);
digitalWrite(segD, HIGH);
digitalWrite(segE, LOW);
digitalWrite(segF, HIGH);
digitalWrite(segG, HIGH);
break;
if (COUNT<10)
{
COUNT++;
delay(1000);///increment count integer for every second
}
if (COUNT==10)
{
COUNT=0;// if count integer value is equal to 10, reset it to zero.
delay(1000);
}
Result:
34
Exp. 4: SERIAL COMMUNICATION
Aim:
1. To establish serial communication between Arduino Uno and PC
2. To receive a number through serial communication and display it in 7 segment display.
Components Requirement:
Theory:
35
Code Structure
void setup() {
// put your setup code here, to run once:
void loop() {
// put your main code here, to run repeatedly:
setup : It is called only when the Arduino is powered on or reset. It is used to initialize variables and
pin modes
loop : The loop functions runs continuously till the device is powered off. The main logic of the code
goes here. Similar to while (1) for micro-controller programming.
PinMode
Pre Lab:
1. What is serial communication?
2. What is baud rate?
Lab Procedure:
1. Connect the Arduino Uno Development Board to the Desktop/Laptop through Type B USB
cable.
2. Write the code and compile it in Arduino IDE.
3. Select USB port in Arduino IDE.
4. Select Arduino Uno Development Board in Arduino IDE.
5. Download the code into Arduino Uno Development Board
6. Run the code in Arduino Uno Development Board.
7. Observe and verify the output.
Post Lab:
1. How do you establish serial communication between Arduin and PC?
2. In the code, explain the statement
COUNT = Serial.read()-48;
Output:
{
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
pinMode(12, OUTPUT);
}
void loop()
{
switch (COUNT)
{
case 0://when count value is zero show”0” on disp
digitalWrite(segA, HIGH);
digitalWrite(segB, HIGH);
digitalWrite(segC, HIGH);
digitalWrite(segD, HIGH);
digitalWrite(segE, HIGH);
digitalWrite(segF, HIGH);
digitalWrite(segG, LOW);
break;
break;
digitalWrite(segA, HIGH);
digitalWrite(segB, HIGH);
digitalWrite(segC, LOW);
digitalWrite(segD, HIGH);
digitalWrite(segE, HIGH);
digitalWrite(segF, LOW);
digitalWrite(segG, HIGH);
break;
digitalWrite(segA, HIGH);
digitalWrite(segB, HIGH);
digitalWrite(segC, HIGH);
digitalWrite(segD, HIGH);
digitalWrite(segE, LOW);
digitalWrite(segF, LOW);
digitalWrite(segG, HIGH);
break;
digitalWrite(segA, LOW);
38
digitalWrite(segB, HIGH);
digitalWrite(segC, HIGH);
digitalWrite(segD, LOW);
digitalWrite(segE, LOW);
digitalWrite(segF, HIGH);
digitalWrite(segG, HIGH);
break;
digitalWrite(segA, HIGH);
digitalWrite(segB, LOW);
digitalWrite(segC, HIGH);
digitalWrite(segD, HIGH);
digitalWrite(segE, LOW);
digitalWrite(segF, HIGH);
digitalWrite(segG, HIGH);
break;
digitalWrite(segA, HIGH);
digitalWrite(segB, LOW);
digitalWrite(segC, HIGH);
digitalWrite(segD, HIGH);
digitalWrite(segE, HIGH);
digitalWrite(segF, HIGH);
39
digitalWrite(segG, HIGH);
break;
digitalWrite(segA, HIGH);
digitalWrite(segB, HIGH);
digitalWrite(segC, HIGH);
digitalWrite(segD, LOW);
digitalWrite(segE, LOW);
digitalWrite(segF, LOW);
digitalWrite(segG, LOW);
break;
digitalWrite(segA, HIGH);
digitalWrite(segB, HIGH);
digitalWrite(segC, HIGH);
digitalWrite(segD, HIGH);
digitalWrite(segE, HIGH);
digitalWrite(segF, HIGH);
digitalWrite(segG, HIGH);
break;
digitalWrite(segA, HIGH);
digitalWrite(segB, HIGH);
digitalWrite(segC, HIGH);
40
digitalWrite(segD, HIGH);
digitalWrite(segE, LOW);
digitalWrite(segF, HIGH);
digitalWrite(segG, HIGH);
break;
break;
}
while(!Serial.available());
COUNT = Serial.read()-48;
Serial.println(COUNT);
/*
if (COUNT<10)
{
COUNT++;
delay(1000);///increment count integer for every second
}
if (COUNT==10)
{
COUNT=0;// if count integer value is equal to 10, reset it to zero.
delay(1000);
}*/
}
Result:
41
Laboratory Report Cover Sheet
Name :
Register No. : RA
Day / Session : DAY-4/AN
Venue :
Title of Experiment : EXPERIMENT-4 (TIMER PROGRAMMING)
Date of Conduction : 05.02.2021
Date of Submission :
REPORT VERIFICATION
Date :
Staff Name :
Signature :
42
Experiment 4: TIMER PROGRAMMING
Aim:
1. To generate delay using timer programming using Arduino Uno and PC
Components Requirement:
Theory:
Timer in AVR
Many time we need our Application to wait for some time and retain its stage as it is – it is that time
when we need to delay our CPU i.e waste our CPU cycle. A timer is simply a register of 8 or 16 bit
size. And these values like 16 or 8 bit signifies the Resolution of a timer i.e till what value it can
count. It basically means it can count from 0 to 2^8 255. . Likewise, a 16 bit timer can hold a value
between 0 to 65535.
This Timer register(Timer value storing register) has a property of increasing or decreasing its value
without any intervention by CPU at a rate frequently defined by the user. This frequency (at which the
timer register increases/decreases) is known as the Timer Frequency. Note that Timer Frequency can
be less than or equal to the CPU clock frequency.
ATmega328P have 3 different timers, of which the simplest one is TIMER0, with an 8 bit (0-255)
resolution.
When the counter overflows or reaches 0x00, the output signal is asserted. The output signal may
thereby trigger an interrupt at the processor or set a bit/Flag that the processor can read. To restart the
timer, software reloads the count register with the same or a different initial value.
43
Prescaler: As we already discussed that the Timer frequency can be less than or equal to the CPU clock
frequency. Then how are we decide or set the timer frequency as per our needs? Here the “Prescaler”
comes in picture. This is actually a method of generating the clock frequency for the TIMER from the
CPU clock by dividing it with a suitable number.
Overflow: The timer in some conditions automatically take an action or informs the CPU to suspend
the current execution, by an Interrupt signal. One example of this is the Timer Overflow, i.e an 8 bit
timer has counted upto its maximum value (255) and revert to 0.Here, the timer sends a signal or
interrupt to the CPU to break its current execution and execute the ISR (interrupt service routine). ISR
is a function that the CPU should execute whenever an interrupt occurs. The programmer must write
into the ISR to handle the interrupt.
After understanding the terms like Prescaler and overflow comes the next point i.e what are the
registers involved in programming a timer according to our needs.The registers description can be
found in Register Description section of datasheet.
Register description
So the registers involved are as following:
This register controls the mode in which Timer will work. On setting and resetting the value
of COM0A1:0 bits we can also control the behaviour of output compare pin (OC0A). However, note
that the data direction register (DDR) bit corresponding to the OC0A pin must be set in order to enable
the output driver.
However WGM01:0( Waveform Generation Mode) combined with the WGM02 bit found in the
TCCR0B register are used to control the counting sequence of the counter, the source for maximum
(TOP) counter value, and what type of waveform would be generated. And thus decide in which mode
timer will operate.
In AVR we have various modes of operations for a timer. And those are as following-
1. Normal Mode
Thus according to how your counting will start and which register you want to use for counting you
can decide in which mode you want your timer to count.
This register is used to set the pre-scalar and along with TCCRxA we can decide the type of waveform
generated. CS02:0 (Clock Select) these three are clock select bits which are used to select the clock
source to be used by the Timer/Counter.
45
6. TIMSK0 – Timer/Counter Interrupt Mask Register
This register is used for setting up the local timer interrupt. If I bit is set then after setting bits here the
timer interrupt is enabled.
Time period taken in one clock tick =1/frequency = 1/ (16*10^6) = 0.0625 us =0.0625*10^-6
So to complete 1 sec your clock will tick for 1/ (0.0625*10^-6) = 16,000,000 times.
Thus if you are creating a delay for 1 sec then you need to count for 16,000,000 times. But since our 8
bit timer can only count up-to 255 and our 16 bit timer can only count up-to 65,536 so we need some
other method to reduce the count. To do that our prescaler comes into picture.
So, we will use divide by 1024 now when we divide our clock frequency
Time period taken in one clock tick =1/frequency = 1/15,625 = 64 us =64 *10^-6
46
So to complete 1 sec your clock will tick for 1/(64*10^6)=15,625 times
Thus, now if our 8 bit timer will count for 255 times it will cover only 255*64*10^-6 = 266*64 us =
16.32 ms
So how many time does our timer should count to 255 so as to get 1 sec.
Lab Procedure:
8. Connect the Arduino Uno Development Board to the Desktop/Laptop through Type B USB
cable.
9. Write the code and compile it in Arduino IDE.
10. Select USB port in Arduino IDE.
11. Select Arduino Uno Development Board in Arduino IDE.
12. Download the code into Arduino Uno Development Board
13. Run the code in Arduino Uno Development Board.
14. Observe and verify the output.
Post Lab:
3. Calculate the hexadecimal value to be loaded in TCNT0 register to generate 10ms of delay by
considering 8MHz CPU frequency.
CODE FOR DELAY GENERATION USING TIMERS (TO BLINK THE LED WITH TIMER
BASED DELAY):
#include<avr/io.h>
#include<util/delay.h>
#include<avr/interrupt.h>
int count=0;
void timer0_init()
{
CLR(TCCR0A,WGM00);//SET TIMER0 TO NORMAL MODE
CLR(TCCR0A,WGM01);
CLR(TCCR0B,WGM02);
TCNT0=0X00;
SET(SREG,7);
47
SET(TIMSK0,TOIE0); // overflow interrupt enable
}
void enable_timer()
{
SET(TCCR0B,CS00);//set prescalar to 1024
CLR(TCCR0B,CS01);
SET(TCCR0B,CS02);
}
int main()
{
DDRB|=(1<<PB5); //LED CONNECTED TO DIGITAL PIN 13 ,and all the
//bits of the port is set so as to make it an
//output port
timer0_init();
enable_timer();
while(1)
{
if(count==62)
{
TOGGLE(PORTB,PB5);
count=0;
}
}
}
ISR(TIMER0_OVF_vect)
{
count++;
}
Result:
48
Lab 6: Sensor Interfacing For Displacement Measurement
Aim: To indicate the distance range using three LEDs and use ultrasonic sensor to measure distance.
Components Requirement:
Theory:
Ultrasonic sensor HC-SR04 is used here to measure distance in range of 2cm-400cm with accuracy
of 3mm. The sensor module consists of ultrasonic transmitter, receiver and the control circuit. The
working principle of ultrasonic sensor is as follows:
49
Code Structure
void setup() {
// put your setup code here, to run once:
void loop() {
// put your main code here, to run repeatedly:
PinMode
Prelab :
1. What are ultrasonic sensors?
2. What environmental conditions affect an ultrasonic sensor?
Lab Procedure:
1. Connect the Arduino Uno Development Board to the Desktop/Laptop through Type B USB
cable.
2. Make the circuit connection accordingly.
3. Write the code and compile it in Arduino IDE.
4. Select USB port in Arduino IDE.
5. Select Arduino Uno Development Board in Arduino IDE.
6. Download the code into Arduino Uno Development Board
7. Run the code in Arduino Uno Development Board.
8. Observe and verify the output.
Post Lab:
1. Write a note on the Arduino function used to detect the length of a pulse.
2. What is a dead zone in ultrasonic ranging?
50
Output:
Code.
long cm = 0;
void setup()
{
Serial.begin(9600);
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
}
void loop()
{
51
cm =readUltrasonicDistance(7, 6);
Serial.print(cm);
Serial.println("cm");
RESULT :
52
Exp. 7: DC MOTOR INTERFACE
Aim:
To run a DC motor with the help of a motor driver(L239D) using Arduino Uno.
Components Requirement:
Software Tools: Arduino IDE, Tinkercad online Virtual Lab (For simulation)
Theory:
The L293D is a popular 16-Pin Motor Driver IC. As the name suggests it is
mainly used to drive motors. A single L293D IC is capable of running two DC
motors at the same time; also the direction of these two motors can be
controlled independently.
1 Enable 1,2 This pin enables the input pin Input 1(2) and Input 2(7)
8 Vcc2 (Vs) Connected to Voltage pin for running motors (4.5V to 36V)
9 Enable 3,4 This pin enables the input pin Input 3(10) and Input 4(15)
54
Features
Code Structure:
void setup()
{
// put your setup code here, to run once:
}
void loop()
{
// put your main code here, to run repeatedly:
55
}
Pre-Lab Questions:
1. What is DC motor?
2. On what principle DC motor works?
Procedure:
Note:
We use a slide switch to alter the direction of rotation of the motor. When
the slide switch is in the left side, the DC motor rotates in an anticlockwise
fashion. When switch slides to the right, the DC motor rotates in clockwise
direction.
56
Post Lab:
Output
Code:
void setup()
{
pinMode(13, OUTPUT); // enable l293d
pinMode(11,OUTPUT); // input 1
pinMode(9,OUTPUT); // input 2
Aim:
To interface a Servo Motor using PWM Signals.
Components Requirement:
Hardware components: (i) Desktop/ Laptop (Host)
(ii) Arduino Uno Development Board (Target)
(iii) Type B USB Cable
Software Tools: Arduino IDE, Tinkercad online Virtual Lab (For simulation)
58
Theory:
A servomotor is a rotary actuator or linear actuator that allows for precise control of angular or linear
position, velocity and acceleration. It consists of a suitable motor coupled to a sensor for position
feedback. It also requires a relatively sophisticated controller, often a dedicated module designed
specifically for use with servomotors.
Servomotors are not a specific class of motor, although the term servomotor is often used to refer to a
motor suitable for use in a closed-loop control system.
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. This on-off pattern can
simulate voltages in between the full Vcc of the board (e.g., 5 V on Uno, 3.3 V on a MKR board) and
off (0 Volts) by changing the portion of the time the signal spends on versus the time that the signal
spends off.
Code Structure
void setup() { // put your setup
code here, to run once:
59
}
void loop() { // put your main code here, to run repeatedly:
}
Lab Procedure:
1. Connect the Arduino Uno Development Board to the Desktop/Laptop through Type B USB cable.
2. Make the circuit connection accordingly.
3. Write the code and compile it in Arduino IDE.
4. Select USB port in Arduino IDE.
5. Select Arduino Uno Development Board in Arduino IDE.
6. Download the code into Arduino Uno Development Board
7. Run the code in Arduino Uno Development Board.
8. Observe and verify the output.
CODE:
#include <Servo.h>
int pos = 0;
Servo servo_9;
void setup()
{
servo_9.attach(9);
}
void loop()
{
for (pos = 0; pos<= 180; pos += 1) {
servo_9.write(pos);
delay(15);
}
for (pos = 180; pos>= 0; pos -= 1) {
60
servo_9.write(pos);
delay(15);
}
}
CODE:
int sensorValue = 0;
int outputValue = 0;
void setup() {
pinMode(A0, INPUT);
pinMode(9, OUTPUT);
Serial.begin(9600);
}
void loop(){
sensorValue = analogRead(A0);
outputValue = map(sensorValue, 0, 1023, 0, 255);
analogWrite(9, outputValue);
Serial.print("sensor =");
Serial.print(sensorValue);
Serial.print("\toutput =");
61
Serial.println(outputValue);
delay(2);
}
Aim:
To interface two Arduino using I2C Communication
Components Requirement:
Hardware components: (i) Desktop/ Laptop (Host)
(ii) Arduino Uno Development Board (Target)
(iii) Type B USB Cable
Software Tools: Arduino IDE, Tinkercad online Virtual Lab (For simulation)
Theory:
The I2C protocol involves using two lines to send and receive data: a serial clock pin (SCL) that the
Arduino or Genuino Master board pulses at a regular interval, and a serial data pin (SDA) over which
62
data is sent between the two devices. As the clock line changes from low to high (known as the rising
edge of the clock pulse), a single bit of information - that will form in sequence the address of a
specific device and a a command or data - is transferred from the board to the I2C device over the
SDA line. When this information is sent - bit after bit -, the called upon device executes the request
and transmits it's data back - if required - to the board over the same line using the clock signal still
generated by the Master on SCL as timing.
Code Structure
void setup() {
// put your setup code here, to run once:
void loop() {
// put your main code here, to run repeatedly:
Lab Procedure:
1. Connect the Arduino Uno Development Board to the Desktop/Laptop through Type B
USB cable.
2. Make the circuit connection accordingly.
3. Write the code and compile it in Arduino IDE.
4. Select USB port in Arduino IDE.
63
5. Select Arduino Uno Development Board in Arduino IDE.
6. Download the code into Arduino Uno Development Board
7. Run the code in Arduino Uno Development Board.
8. Observe and verify the output.
Post lab Questions:
1) List the functions done by Wire.beginTransmission(address).
CODE:
Arduino 1:
#include
<Wire.h> int
analogIN = 0; int
msg = 0;
void setup() {
pinMode(A0, INPUT);
// Start the I2C Bus as Master
Wire.begin();
Serial.begin(9600);
Serial.print("Welcome to I2C Demo. I am Arduino
1"); }
void loop(){
analogIN=analogRead(A0);
msg = map(analogIN, 0, 1023, 0, 255);
Wire.beginTransmission(9); // transmit to device #9
64
Wire.write(msg); // sends x
Wire.endTransmission(); // stop transmitting
Serial.println(msg);
delay(500);
}
Arduino 2:
#include
<Wire.h> int
LED = 13; int x
= 0; void
setup() {
// Define the LED pin as Output
pinMode (LED, OUTPUT);
Serial.begin(9600);
// Start the I2C Bus as Slave on address 9
Wire.begin(9);
// Attach a function to trigger when something is received.
Wire.onReceive(receiveEvent);
}
}
//If value received is 3 blink LED for 400
ms if (x ==4) {
digitalWrite(LED,
HIGH); delay(400);
digitalWrite(LED, LOW);
delay(400);
}
}
65
RESULT:
Software Tools: Arduino IDE, Tinkercad online Virtual Lab (For simulation)
Theory:
An Interrupt's job is to make sure that the processor responds quickly to important events.
When a certain signal is detected, an Interrupt (as the name suggests) interrupts whatever the
processor is doing, and executes some code designed to react to whatever external stimulus is
being fed to the Arduino.
66
Code Structure
void setup() {
// put your setup code here, to run once:
void loop() {
// put your main code here, to run repeatedly:
Lab Procedure:
1. Connect the Arduino Uno Development Board to the Desktop/Laptop through Type B
USB cable.
67
2. Make the circuit connection accordingly.
3. Write the code and compile it in Arduino IDE.
4. Select USB port in Arduino IDE.
5. Select Arduino Uno Development Board in Arduino IDE.
6. Download the code into Arduino Uno Development Board
7. Run the code in Arduino Uno Development Board.
8. Observe and verify the output.
CODE:
void setup() {
pinMode(LED_Pin, OUTPUT);
pinMode(BUZZER_Pin, OUTPUT);
digitalWrite(LED_Pin, LED_state);
digitalWrite(BUZZER_Pin, BUZZER_state);
68
pinMode(interruptPin2, INPUT_PULLUP);
pinMode(interruptPin3, INPUT_PULLUP);
void loop() {
digitalWrite(LED_Pin, LED_state);
digitalWrite(BUZZER_Pin, BUZZER_state);
Serial.println("0");
}
void blink2() {
LED_state =
!LED_state;
Serial.println("2");
}
void blink3() {
BUZZER_state = !BUZZER_state;
Serial.println("4");
}
RESULT:
69
Exp. 5: SENSOR INTERFACING FOR TEMPERATURE MONITORING
Aim:
To indicate the temperature in “Red”, “Yellow”, “Green” LEDs and also
send the value to terminal in PC via serial port.
Components Requirement:
Software Tools: Arduino IDE, Tinkercad online Virtual Lab (For simulation)
Theory:
The Temperature Sensor LM35 series are precision integrated-circuit temperature devices with an
output voltage linearly proportional to the Centigrade temperature.
The LM35 device has an advantage over linear temperature sensors calibrated in Kelvin, as the user is
not required to subtract a large constant voltage from the output to obtain convenient Centigrade
scaling. The LM35 device does not require any external calibration or trimming to provide typical
accuracies of ±¼°C at room temperature and ±¾°C over a full −55°C to 150°C temperature range. It
is a 3-terminal device that provides analog voltage proportional to the temperature. Higher the
temperature, higher is the output voltage. The output analog voltage can be converted to digital form
using ADC so that a microcontroller can process it.
70
Code Structure:
void setup()
{
// put your setup code here, to run once:
}
void loop()
{
// put your main code here, to run repeatedly:
}
Pre-Lab Questions:
Note:
Red LED should glow when temperature is greater than 70 degree
Celsius
Yellow LED should glow when temperature is greater than 21 degree
Celsius and less than 70 degree Celsius.
Green LED should glow when temperature is Less than 20 degree
Celsius
Post Lab:
Output:
72
Code:
int sensorValue = 0;
int SerialValue = 0;
void setup()
pinMode(A0, INPUT);
Serial.begin(9600);
void loop()
sensorValue = analogRead(A0);
73
SerialValue = (sensorValue-102)/2;
Serial.println(SerialValue);
if (SerialValue>70)
digitalWrite(13,HIGH);
digitalWrite(12,LOW);
digitalWrite(11,LOW);
digitalWrite(13,LOW);
digitalWrite(12,LOW);
digitalWrite(11,HIGH);
if(SerialValue<20)
digitalWrite(13,LOW);
digitalWrite(12,HIGH);
digitalWrite(11,LOW);
}
74
delay(2); // Wait for 2 millisecond(s)
Result:
Name :
Register No. :
Day / Session :
Venue :
Title of Experiment :
Date of Conduction :
Date of Submission :
REPORT VERIFICATION
Date :
Staff Name :
Signature :
Aim:
1. To interface LCD to Arduino (Display text and characters on LCD screen using Arduino)
Components Requirement:
Theory:
In this experiment, we’re learning how to interface LCD to Arduino and display text characters on
LCD screen. We’re interfacing 16×2 LCD to Arduino as a demonstration with circuit and code.
A Liquid Crystal Display commonly abbreviated as LCD is basically a display unit built
using Liquid Crystal technology. In order to build real life/real world electronics based projects, we
need a medium/device to display output values and messages. The most basic form of electronic
display available is 7 Segment display – which has its own limitations. The next best available option
is Liquid Crystal Displays which comes in different size specifications. Out of all available LCD
modules in market, the most commonly used one is 16×2 LCD Module which can display 32 ASCII
characters in 2 lines (16 characters in 1 line).
76
The name and functions of each pin of the 16×2 LCD module is given below.
Pin1(Vss):Ground pin of the LCD module.
Pin2(Vcc): Power to LCD module (+5V supply is given to this pin)
Pin3(VEE):Contrast adjustment pin. This is done by connecting the ends of a 10K potentiometer to
+5V and ground and then connecting the slider pin to the VEE pin. The voltage at the VEE pin defines
the contrast. The normal setting is between 0.4 and 0.9V.
Pin4(RS):Register select pin.The JHD162A has two registers namely command register and data
register. Logic HIGH at RS pin selects data register and logic LOW at RS pin selects command
register. If we make the RS pin HIGH and feed an input to the data lines (DB0 to DB7), this input will
be treated as data to display on LCD screen. If we make the RS pin LOW and feed an input to the data
lines, then this will be treated as a command ( a command to be written to LCD controller – like
positioning cursor or clear screen or scroll).
Pin5(R/W): Read/Write modes. This pin is used for selecting between read and write modes. Logic
HIGH at this pin activates read mode and logic LOW at this pin activates write mode.
Pin6(E): This pin is meant for enabling the LCD module. A HIGH to LOW signal at this pin will
enable the module.
Pin7(DB0) to Pin14(DB7): These are data pins. The commands and data are fed to the LCD module
though these pins.
Pin15(LED+): Anode of the back light LED. When operated on 5V, a 560 ohm resistor should be
connected in series to this pin. In arduino based projects the back light LED can be powered from the
3.3V source on the arduino board.
Pin16(LED-): Cathode of the back light LED.
77
Pre-lab Questions:
1) List and describe the important control signals of LCD?
2) Write the advantages of LCD over the LED display.
#include<LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2); // sets the interfacing pins
void setup( )
{
lcd.begin (16, 2); // initializes the 16x2 LCD
}
Void loop ( )
{
--
--
78
}
Post-Lab Questions:
1) Write an ATMega328P Arduino C program to send letters “SRMIST” to the LCD display. Test the
output in Tinkercad and paste the output result here.
RESULT:
79