Introduction to Arduino

LCD Display with Dimmer and Photoresistor

Arduino UNO R3 Pin Setup


    This project adds a 16 character by 2 line Liquid Crystal Display (LCD) to your project which allows you to view data in real time without being tethered to your computer. The brightness of the LCD can be adjusted with a potentiometer.

    The readout for this project consists of a static top line of text “Brightness:” and a second line showing the value coming from the photoresistor.

    If you have not already done so, you need to install a library. These are easy to install and only need to be installed once. Go to Tools / Manage Libraries and search for (and install) LiquidCrystal.

Parts List:
    1 1602 (16x2) LCD Display
    1 220 Ohm Resistor
    1 10K Ohm Resistor
    1 Potentiometer
    1 Photoresistor
    1 Arduino UNO R3
    1 Breadboard
    Connector Wires


    //------------- Code Starts Here ----------------------------
    //Published by
    //Created by Paul Illsley (
    //Please use and share so others can enjoy
    // including the LiquidCrystal library
    #include <LiquidCrystal.h>
    // assigning LCD pins to arduino pin numbers 
    const int rs = 12;
    const int en = 11;
    const int d4 = 5;
    const int d5 = 4;
    const int d6 = 3;
    const int d7 = 2; 
    LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
    // creating an integer (int) variable called “light” to hold the photoresistor value
    int light;
    void setup() {
      // declaring the number of columns and rows in the LCD (16 characters and 2 rows)
      lcd.begin(16, 2);
      // print text to the LCD. This will stay on the top line
    void loop() {
      // reading the value from pin A1 (the photoresistor) and placing it in "light"
      light = analogRead(A1);
      // set the cursor location to column 0, line 1 (this is the second line since the first line would be 0,0)
      lcd.setCursor(0, 1);
      // print the photoresistor value 
      // delay 500 milliseconds (0.5 seconds) to make the display easier to read (this delay is optional)
    //------------- Code Stops Here ----------------------------

    Created by Paul Illsley

    Return to