Connecting a 1602A LCD display and a light sensor to Arduino UNO

21 October 2012

This tutorial shows how to connect the 1602A LCD display and a light sensor to your Arduino (UNO) and display the light intensity on the screen. I am using only parts from the Arduino starter kit I got from Deal Extreme.

This is one of the first things I try with the Arduino, but since I could not find one tutorial that covered the combination of using the LCD screen ánd the light sensor, I decided to write one beginner tutorial. Also there are many different versions of the 1602 LCD display with different pinouts and I couldn't really find which the DX version exactly was.

Materials used

1 x Arduino UNO
1 x Breadboard (63 columns)
1 x Light sensor
1 x 50K pot meter
1 x 1602A LCD display
1 x 10K resistor
1 x Connector (16 pins)
1 x USB cable

The LCD display

The LCD display comes with no connector by default. This way you can solder wires to it, solder a connector on it, whatever you want. I choose to solder the connectors to the back so I could press the LCD display on the breadboard. To do this, snap of a row of connectors (16 pieces) and stick them (short pin up) trough the LCD display connectors.

Stick the LCD display in the breadboard, somewhere on the right in the lowest row of holes so you can connect the breadboard wires above and the display rests on the unused rows of the breadboard.

Connecting the display and breadboard

First you need to power the display and its backlight. Connect two wires from +5v and GND to the plus- and min rows of the breadboard.

Connect: Arduino 5v (pin 3) > plus column on breadboard
Connect: Arduino GND (pin 4 or 5) > min column on breadboard

Then connect the LCD power and the backlight power to the plus- and min rows.

Connect: GND row (min) on breadboard > pin 1 on LCD (VSS)
Connect: +5v row (plus) on breadboard > pin 2 on LCD (VDD)
Connect: +5v row (plus) on breadboard > pin 15 on LCD (A)
Connect: GND row (min) on breadboard > pin 16 on LCD (K)

When we power up the Arduino (by plugin in the USB cable connected to the computer) we'll see the LCD screen lighting up:

Next up is the pot meter. We use the potmeter to set the contrast of the display. In most LCD tutorials a 10K pot meter is used, but a 50K is also good. Finetuning gets a little harder because the range is bigger, but that's no problem for this tutorial. Plug the pot meter in the breadboard, somewhere left of the LCD display and connect the three pins.

Connect: first pin of the potmeter > GND of the breadboard
Connect: middle pin of the potmeter > pin 3 of the LCD display (VO)

When you power up the Arduino now, you will see the display having square characters on the first row. Of you don't see them, turn the pot meter slowly from left to right to adjust the contrast. You can finetune this setting when we've got characters on the display later. If your display looks like this, you're doing fine:

In the next few steps we'll connect the display further to the Arduino to let the arduino communicate with the LCD screen and put some characters on it.

Connect: pin 4 of the LCD display (RS) > pin 7 of the Arduino (digital out, PWM, yellow wire)
Connect: pin 5 of the LCD display (RW) > GND row of the breadboard (black wire)

Connect: pin 6 of the LCD display (E) > pin 8 of the Arduino (PWM)
Connect: pin 11 of the LCD display (D4) > pin 9 of the Arduino (PWM)
Connect: pin 12 of the LCD display (D5) > pin 10 of the Arduino (PWM)
Connect: pin 13 of the LCD display (D6) > pin 11 of the Arduino (PWM)
Connect: pin 14 of the LCD display (D7) > pin 12 of the Arduino (PWM)

The code

Now open a new sketch in the Arduino editor, copy-paste this code and upload it to the Arduino:

#include <LiquidCrystal.h>

LiquidCrystal lcd(7, 8, 9, 10, 11 , 12);

void setup() {
  lcd.begin(16, 2);
  lcd.write("LIGHT: ");

void loop() { }

When the code is uploaded and running, the LCD will display this text on the second line:

Yay! This is your first "hello world!" on a LCD display. Hooray!

The light sensor

Now lets connect the light sensor and display its value on the LCD screen. Connect three wires to empty columns on the breadboard. Make sure they are a few columns apart to have a little space for the sensor and the resistor.

Connect: GND row of the breadboard > free column 1
Connect: A0 (analog input) on Arduino > free column 2
Connect: +5 row of the breadboard > free column 3

Then bend the legs of the sensor and the resistor and put them in the columns you connected the wires to. Both the sensor and the resistor can be connected to both sides, so it doesn't matter if you put them in left- or rightside first.

Connect: light sensor > column 1 and column 2
Connect: resistor > column 2 and column 3

Now go back to the Arduino sketch program and replace the empty "loop" function with this new lines:

void loop() {
  int sensorValue = analogRead(A0);

If you upload it to the Arduino and it runs, you'll see the current measurement of the light sensor:

If you switch your desktop light on and off you'll see the value of the light sensor change.

That's it! You have created a LCD display which displays the current light value in your room!
You must have JavaScript enabled to use this form!

Leave a comment!

  1. Your mail is safe with me. It's only only used to display your Gravatar image!


Previous Page 1 of 5 Next
  1. Johan van Tongeren Gravatar

    José Torres

    06 February 2016

    Thank you! It worked from the first try. Now I am adding some code to turn on/off a led depending on light intensity. Great tutorial.

  2. Johan van Tongeren Gravatar

    Craig Paardekooper

    06 February 2016

    In your void setup() code I believe that you missed a command -

    pinMode(A0, INPUT);

    Without this command the screen remains blank.

  3. Johan van Tongeren Gravatar


    21 January 2016

    helo yor prođekt vas veri gud. thenk ju

  4. Johan van Tongeren Gravatar

    okoli franklin

    24 December 2015

    this is actually my first helloo

  5. Johan van Tongeren Gravatar

    grant everson

    28 October 2015

    First time I have tried to do anything with the lcd. I am bran new to Hello world stuff. An old man with way too much time left to sit and do nothing. This was a wonderful way to have fun and the way you layed it out was super. Grant Everson

  6. Johan van Tongeren Gravatar

    Bijaya Dixit

    22 October 2015

    This is good demo and tutorial. easy to understand. I am a first timer in arduino. I was having trouble to understand the connection of this LCD1602A v2.0. I researched a lot in google and finally this site give me the success. Remember if your connection of LCD pin to arduino pin is important.

  7. Johan van Tongeren Gravatar

    chandan gupta

    20 August 2015

    nice to understand

  8. Johan van Tongeren Gravatar


    09 July 2015

    We have triple checked our wiring. Everything was correct, but the message "LIGHT" would not display on the LCD. I believe it might be the wiring that's connected to the left of the LCD. Maybe if you made the picture more clear, it could have been more successful.

  9. Johan van Tongeren Gravatar


    08 July 2015

    Thank you for providing a good guide for testing an LCD.
    I hooked up all the wires as directed, but the LCD does not
    disply the message, "LIGHT:". The LCD works fine with the
    first row with a row of small rectangles.
    I double-checked all the connections.
    Could you give me a tip to fix my problem?

  10. Johan van Tongeren Gravatar

    Johan Cornelis

    04 July 2015

    After letting some LED blink and monitoring a temperature or a light sensor the liquid crystal display was the next step. I found it somewhat daunting to start with.
    Your tutorial worked perfect for me.
    Thanks a lot.

    Heel erg bedankt.

Previous Page 1 of 5 Next