Sunteți pe pagina 1din 3

Interfacing LCD and LDR in Arduino platform

Mayank Mittal(B17093)
Aman Verma(B17114)
Hardik Aggarwal(B17086)

Abstract—LCD(liquid crystal display) is connected with arduino A. Hello World


board to show the desired output by writing the data into LCD’s void setup() {
memory/data registers. LCDs are good for displaying information // set up the LCD’s number of columns and rows:
like sensors data.This experiment uses 4-bit mode which requires lcd.begin(16, 2);
7 digital I/O pins. LDR is used to vary the voltage in circuit by // Print a message to the LCD.
reducing/increasing the intensity of light falling on the LDR. lcd.print(”hello, world!”);
Keywords— LDR, LCD, Registers }
// the loop function runs over and over again forever
void loop()
I. I NTRODUCTION {
A liquid crystal display, or LCD, is a video display that utilizes // set the cursor to column 0, line 1
the light modulating properties of liquid crystals to display pictures // note: line 1 is the second row, since counting begins with
or text on a screen. The LCDs have a parallel interface, meaning that 0:
the microcontroller has to manipulate several interface pins at once lcd.setCursor(0, 1);
to control the display. Some of the pins are: - // print the number of seconds since reset:
lcd.print(millis() / 1000);
• Register Select pin }
• Read/Write pins
• Enable pin B. Scroll
• Data pins void setup()
LDR is light dependent resistance which has the following property {
// set up the LCD’s number of columns and rows:
1 lcd.begin(16, 2);
resistance ∝ (1) // Print a message to the LCD.
intensity of light
lcd.print(”hello, world!”);
This property can be utilized to vary voltage in circuit by varying the delay(1000);
light intensity. }
// the loop function runs over and over again forever
void loop()
II. WORK DONE {
// scroll 13 positions (string length) to the left
This experiment has three tasks: // to move it offscreen left:
• Display the hello world on LCD. for (int positionCounter = 0; positionCounter < 13;
• Scroll the hello world on LCD. positionCounter++)
• Display custom character. {
// scroll one position left:
. Arduino Code : lcd.scrollDisplayLeft();
// wait a bit:
delay(150);
}
// scroll 29 positions (string length + display length) to the
right
// to move it offscreen right:
for (int positionCounter = 0; positionCounter < 29;
positionCounter++)
{
// scroll one position right:
lcd.scrollDisplayRight();
// wait a bit:
delay(150);
}
// scroll 16 positions (display length + string length) to the
left
// to move it back to center:
Fig. 1. LCD pin connections with arduino [3]
for (int positionCounter = 0; positionCounter < 16;
positionCounter++)
{ }
// scroll one position left: void loop()
lcd.scrollDisplayLeft(); { // read the potentiometer on A0:
// wait a bit: int sensorReading = analogRead(A0);
delay(150); // map the result to 200 - 1000:
} int delayTime = map(sensorReading, 0, 1023, 200,
// delay at the end of the full loop: 1000);
delay(1000); // set the cursor to the bottom row, 5th position:
} lcd.setCursor(4, 1);
// draw the little man, arms down:
C. Custom character lcd.write(3);
• 1. Displaying battery delay(delayTime);
include<LiquidCrystal.h> lcd.setCursor(4, 1);
LiquidCrystaal lcd(12,11,5,4,3,2) // draw him arms up:
byte battery[8] = { lcd.write(4);
0b00100, delay(delayTime);
0b01110, }
0b01110,
0b01110, D. LDR circuit
0b11111, The LDR gives out an analog voltage when connected to VCC, which
0b11111, varies in magnitude in direct proportion to the input light intensity
0b11111, on it.It is connected to the analog input pin on the Arduino. The
0b11111 Arduino, with in-built ADC (analog 0-5V) into a digital value in the
}; range of (0-1023). When there is sufficient light is its environment
void setup() or on its surface, the connected digital values read from the LDR
{ // initialize LCD and set up the number of columns and through the Arduino will be in the range of 800-1023.
rows: Arduino code:
lcd.begin(16, 2); int sensorPin = A0; // select the input pin for LDR
create a new character int sensorValue = 0; int voltage;// variable to store the value coming
lcd.createChar(0, battery); from the sensor void setup()
} {
void loop() Serial.begin(9600); //sets serial port for communication
{ // read the potentiometer on A0: }
int sensorReading = analogRead(A0); void loop()
// map the result to 200 - 1000: {
int delayTime = map(sensorReading, 0, 1023, 200, sensorValue = analogRead(sensorPin); // read the value from
1000); the sensor
// set the cursor to the bottom row, 5th position: voltage = sensorValue*5/1024;
lcd.setCursor(4, 1); Serial.println(voltage); //prints the values coming from
// draw the little man, arms down: the sensor on the screen
lcd.write(3); delay(100);
delay(delayTime); }
lcd.setCursor(4, 1); III. E XPERIMENTAL R ESULTS
// draw him arms up:
lcd.write(4); A. Print hello world on LCD
delay(delayTime); Hello world is printed on LCD and ciruit design is shown in Fig. 2.
}
• Displaying smilie
include<LiquidCrystal.h>
LiquidCrystal lcd(12,11,4,5,3,2)
byte smilie[8] =
{
0b00000,
0b10001,
0b00000,
0b00000,
0b10001,
0b10001,
0b01110,
0b00000
};
void setup() Fig. 2. LCD interfacing with arduino
{ // initialize LCD and set up the number of columns and
rows:
lcd.begin(16, 2); B. Scroll
create a new character Hello world is scrolled and circuit design is shown in Fig. 3 and Fig.
lcd.createChar(0, smilie); 4.

Page 2 of 3
Fig. 3. Hello World scrolling (instant1) Fig. 6. LDR circuit for varying voltage with intensity

Fig. 7. Voltage on Serial monitor as light intensity is varied

Fig. 4. Hello World scrolling (instant2)


IV. C ONCLUSION
We can display live output on LCD. This is used for displaying real-
C. Display Custom Character time data at any site where the data is read by sensors.
Voltage in circuit can be changed by changing the intensity of light
falling on LDR. This finds many applications like voltage regulation
in electronic circuits.

R EFERENCES
[1] https://www.arduino.cc/
[2] https://goo.gl/QM6p8z
[3] https://www.engineersgarage.com/electronic-components/16x2-lcd-
module-datasheet
[4] https://www.overleaf.com/project

Fig. 5. Displaying custom character

For the custom character display, code was edited and character
was customized. Then custom character like battery, backslash were
displayed.

D. Detection Light Intensity


In the LDR experiment, we are measuring the varying voltage by
detecting the input light intensity(as shown in the Fig 5). The
analog voltage given by LDR changes according to the light intensity
incident on the LDR.

Page 3 of 3

S-ar putea să vă placă și