0% found this document useful (0 votes)
19 views20 pages

Topic 15 LCD Potentiometer

Uploaded by

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

Topic 15 LCD Potentiometer

Uploaded by

taramev386
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 20

Internet of Things: Concepts and Application

CT101-3-3

LCD, Potentiometer & LDR

Prepared by: NKN First Prepared on: 01.08.18 Last Modified on: 15.11.2019
Quality checked by: SKS & KNT
Copyright 2012 Asia Pacific University of Technology and Innovation
Liquid Crystal Display

Overview LCD, Potentiometer & LDR


In this lesson, we will learn how to measure the
light intensity by photoresistor and make the
16 x 2 LCD measurement result displayed on the LCD1602.

Requirement
 1 Arduino UNO
 1 USB Cable Principle
 1 LCD1602 A photoresistor is a light-controlled variable
 1 Photoresistor resistor. The resistance of a photoresistor
 1 10KΩ Resistor decreases with the increasing incident light
 1 10KΩ Potentiometer intensity; in other words, it exhibits
 1 Breadboard photoconductivity. A photoresistor can be
 Several Jumper Wires applied in light-sensitive detector circuits.

CT101-3-1-IIOT Module Introduction 2


Liquid-Crystal Display (LCD) (1602)

CT101-3-1-IIOT Module Introduction 3


‹#›
Schematic Diagram

CT101-3-1-IIOT Module Introduction 4


‹#›
Circuit Diagram

CT101-3-1-IIOT Module Introduction 5


Step for Circuit Connection

In this program we are turn on and off the backlight by supplying it with 5V
and a potentiometer to control contrast. It has a total number of 16 pins
altogether.

LCD Pin to Arduino Pin 8(D1) => NC


1(Vss) => GND 9(D2) => NC
2(Vdd) => +5V 10(D3) => NC
3(Vee) => Middle pin of potentiometer 11(D4) => digital pin 10
4(RS) => digital pin 8 12(D5) => digital pin 11
5(RW) => GND 13(D6) => digital pin 12
6(E) => digital pin 9 14(D7) => digital pin 13
7(D0) => NC(not connected) 15(A) => +5V
16(K) => GND
CT101-3-1-IIOT Module Introduction 6
Test Brightness of Text & Screen

In this program we are turn on and off the backlight by supplying it with 5V
and a potentiometer to control contrast. It has a total number of 16 pins
altogether.

LCD Pin to Arduino Pin


1(Vss) => GND
2(Vdd) => +5V
3(Vee) => Middle pin of potentiometer
15(A) => +5V
16(K) => GND

CT101-3-1-IIOT Module Introduction 7


Example 1
Display Text
#include <LiquidCrystal.h>
LiquidCrystal lcd(8, 9, 10, 11, 12, 13);

void setup()
{
lcd.begin(16, 2);
lcd.print("My Name is:");
}

void loop()
{
lcd.setCursor(0, 1);
}

CT101-3-1-IIOT Module Introduction 8


Example 2
Display text row 1 and 2

#include <LiquidCrystal.h>
LiquidCrystal lcd(8, 9, 10, 11, 12, 13);

void setup()
{
lcd.begin(16, 2);
lcd.print("My Name is:");
lcd.setCursor(0, 1);
lcd.print(“Nathan");
}

void loop()
{

CT101-3-1-IIOT Module Introduction 9


Example 3
Scroll Right & Left
#include <LiquidCrystal.h>
LiquidCrystal lcd(8, 9, 10, 11, 12, 13);

void setup()
{
lcd.begin(16, 2);
}

void loop()
{
lcd.print("Welcome To Malaysia");
lcd.setCursor(0, 0);
lcd.scrollDisplayLeft();
delay(250);
}

CT101-3-1-IIOT Module Introduction 10


Example 4
Count Down Number
#include <LiquidCrystal.h>
LiquidCrystal lcd(8, 9, 10, 11, 12, 13);
void setup()
{
lcd.begin(16, 2);
lcd.print("Count Down...");
}
void loop()
{
lcd.setCursor(0, 1);
lcd.print(millis()/1000);
}

CT101-3-1-IIOT Module Introduction 11


Example 5
Cursor & Blink Position
#include <LiquidCrystal.h>
LiquidCrystal lcd(8, 9, 10, 11, 12, 13);

void setup()
{
lcd.begin(16, 2);
}

void loop()
{
lcd.setCursor(7, 1);
lcd.blink();
delay(3000);
lcd.noBlink();
lcd.setCursor(7, 0);
lcd.cursor();
delay(4000);
lcd.noCursor();
}
CT101-3-1-IIOT Module Introduction 12
Example
Text & Clear Screen
#include <LiquidCrystal.h>
LiquidCrystal lcd(8, 9, 10, 11, 12, 13);

void setup()
{
lcd.begin(16, 2);
}

void loop()
{
lcd.print("Maker Uno");
delay(3000);
lcd.clear();
lcd.setCursor(0,1);
lcd.print("Clear Text");
delay(3000);
lcd.clear();
}
CT101-3-1-IIOT Module Introduction 13
Exercise
Display text “Arduino” with 3 second delay
Display text “LCD Tutorial” at (Col 2, Row 2)
Clear the text
Blink for 4 sec at (Col 7, Row 2)
No blink for 3 sec
Display underscore (line) cursor for 4 sec
No cursor and clear screen
Display “Origin Academy” for 3 sec
Clear screen
CT101-3-1-IIOT Module Introduction 14
Internet of Things: Concepts and Application
CT101-3-3

LiquidCrystal_I2C with 4 Pin

Prepared by: NKN First Prepared on: 01.08.18 Last Modified on: 15.11.2019
Quality checked by: SKS & KNT
Copyright 2012 Asia Pacific University of Technology and Innovation
Schematic Diagram

Download library file for <LiquidCrystal_I2C.h> and <Wire.h>


https://github.com/fdebrabander/Arduino-LiquidCrystal-I2C-library
https://www.resistorpark.com/arduino-wire-library-download/
CT101-3-1-IIOT Module Introduction 16
Hello World!
#include <Wire.h>
#include <LiquidCrystal_I2C.h>

// Set the LCD address to 0x27 for a 16 chars and 2 line display
LiquidCrystal_I2C lcd(0x27, 16, 2);

void setup()
{
// initialize the LCD
lcd.begin();

// Turn on the blacklight and print a message.


lcd.backlight();
lcd.print("Hello, world!");
}

void loop()
{
// Do nothing here...
}

CT101-3-1-IIOT Module Introduction 17


More Text
void loop()
{
#include <Wire.h> lcd.clear();
#include <LiquidCrystal_I2C.h> lcd.print("Hello World!");
delay(1000);
// Set the LCD address to 0x27 for a 16 lcd.clear();
chars and 2 line display
LiquidCrystal_I2C lcd(0x27, 16, 2); lcd.print("I'm powered by");
lcd.setCursor(3, 1);
void setup() lcd.print("Arduino!");
{ delay(1000);
// initialize the LCD lcd.clear();
lcd.begin();
lcd.print("Please subscribe!");
// Turn on the blacklight and print a delay(1000);
message. lcd.clear();
lcd.backlight(); lcd.print("Goodbye!");
//lcd.print("Hello, world!"); delay(1000);
} lcd.clear();
}
CT101-3-1-IIOT Module Introduction 18
Serial Display

void loop()
{
/* Displays text sent over the serial port (e.g. from // If characters arrived over the serial
the Serial Monitor) on an attached LCD. port...
*/ if (Serial.available()) {
#include <Wire.h> // Wait a bit for the entire
#include <LiquidCrystal_I2C.h> message to arrive
delay(100);
// Set the LCD address to 0x27 for a 16 chars and // Clear the screen
2 line display lcd.clear();
LiquidCrystal_I2C lcd(0x27, 16, 2);
// Write all characters
void setup() received with the serial port to the LCD.
{ while (Serial.available() >
lcd.begin(); 0) {
lcd.backlight();
lcd.write(Serial.read());
// Initialize the serial port at a speed of }
9600 baud }
Serial.begin(9600); }
}

CT101-3-1-IIOT Module Introduction 19


Question and Answer Session

Q&A

CT101-3-1-IIOT Module Introduction 20

You might also like