Introduction To Computing (EL116) : Laboratory Manual Fall 2019
Introduction To Computing (EL116) : Laboratory Manual Fall 2019
Introduction To Computing (EL116) : Laboratory Manual Fall 2019
(EL116)
LABORATORY MANUAL
Fall 2019
LAB: 09
INTERFACING WITH ARDUINO
________________________________________
__________
____
STUDENT NAME
ROLL NO
SEC
______________________________________
MARKS AWARDED:/10
______________________________________________________________________
NATIONAL UNIVERSITY OF COMPUTER AND EMERGING SCIENCES (NUCES), ISLAMABAD
Prepared by: Engr. Aamer Munir Version: 1.1
Engr. Ifrah Maqsood
Last edited by:
Engr. Sana Saleh
Date last
Verified by: Engr. Azhar Rauf, Engr. Maryam Wasim Oct18, 2018
edited:
Tools needed:
1. PC running Windows Operating System (OS)
2. ArduinoIDE (installed)
3. Arduino Kit
4. LCD Module
5. Potentiometer (5KΩ or 10KΩ)
6. Resistor of 220Ω
7. Breadboard
8. Jumper wires
Turn on the PC, connect and configure the Arduino provided to you. Run test examples provided
within Arduino IDE to verify if it is properly connected or not.
Note:
The information and concepts discussed in this lab manual
are in sufficient detail but are still not exhaustive. It is
assumed that all these concepts are already taught to you in
your ITC theory class.
A Liquid Crystal Display commonly abbreviated as LCD is basically a display unit built using Liquid
Crystal technology. When we 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 Displayswhich comes in different size specifications. Out of all available LCD modules in
market, the most commonly used one is 16x2 LCD Module which can display 32 ASCII characters in
2 rows (16 characters in 1 row).
The LCD module has 16 pins and can be operated in 4-bit mode or 8-bit mode. Here we are using
the LCD module in 4-bit mode. Before going in to the details of the project, let’s have a look at the
JHD162A LCD module. The pin layout of a JHD162A LCD pin diagram is given below:
The name and function of each pin of the 16×2 LCD module is given below.
Conventionally, the first code to test an output device that can show text is to display the string "Hello
World!" on to it.
#include <LiquidCrystal.h>
void setup()
{
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("Hello, World!");
}
void loop()
{
}
#include <LiquidCrystal.h>
void setup()
{
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("Hello, World!");
}
void loop()
{
// Turn off the display:
lcd.noDisplay();
delay(500);
// Turn on the display:
lcd.display();
delay(1000);
}
It's relatively simple to use an Arduino to measure voltages. The Arduino has several analog input
pins that connect to an analog-to-digital converter (ADC) inside the Arduino. The Arduino ADC is a
10-bit converter, meaning that the output value will range from 0 to 1023. We will obtain this value by
using the analogRead() function. If you know the reference voltage-- in this case we will use 5V--you
can easily calculate the voltage present at the analog input (this is known as calibration).
In this experiment, we will make digital voltmeter capable of measuring up to 5V using an Arduino
board and a 16x2 LCD.
Use a jumper wire connected to Arduino pin A0 to connect to the point whose voltage is to be
measured with respect to the GND.
#include "LiquidCrystal.h"
void setup()
{
Serial.begin(9600); //opens serial port, sets data rate to 9600 bps
lcd.begin(16, 2); //set up the LCD's number of columns and rows:
lcd.print("DVM by i170999");
}
void loop()
{
//Conversion formula for voltage
int analog_value = analogRead(A0);
input_voltage = (analog_value * 5.0) / 1024.0;
Serial.print("v = ");
Serial.println(input_voltage);
lcd.setCursor(0, 1);
lcd.print("Voltage = ");
lcd.print(input_voltage);
delay(300);
}
Note:
You need to understand the interfacing of both LCD and analog input. This knowledge/skill would be
essential for you to be able to complete your ITC Lab Project.
Disclaimer:
This lab manual is based on the information taken from the following websites:
1. http://www.circuitstoday.com/interfacing-lcd-to-arduino
2. https://www.arduino.cc/en/Tutorial/HelloWorld
3. https://www.allaboutcircuits.com/projects/make-a-digital-voltmeter-using-the-arduino/
Important Note:
The marks for this lab will be awarded based on the way you
work during the lab -- the way you build your circuit,
troubleshoot in case something is not working and do
anything the instructor tells you to do.