LCD Screen 16x2 usage with Arduino

LCD Screen 16x2 usage with Arduino

Here we will showcase our final and important project, which in our case is learning how to use a LCD screen so you can write, not only a quote, but actually be able to read values of some sensors and then show those on the screen

Materials and Wiring

The materials needed are:

  • A protoboard
  • A programmable chip (we will be using ESP8266)
  • LCD 16x2 Screen
  • Any type of sensor (we will show how to detect them with a potentiometer)
  • Wires
  • Now to connect everything you need to follow this table below:

    The potentiometer it's not necessary, it's actually there to change the brightness of the LCD screen, but if you just power it directly from the GMD it will run the same, just that you won't be able to regule the brightness

    Once everything setup, it should look something like this:

    The Code

    First, before the setup, we will include the library "LiquidCrystal.h", this is the especial library used with LCD screens and that will read most of the LCD commands and then, we will name all the outputs

    In the void setup, we first will start the LCD with lcd.beggin, a command from the LiquidCrystal.h library. Then, with lcd.print we can write anything that is long 16 words that you want to appear on the upper line

    Then in the void loop, we will use lcd.setCursor to select the lower line, and here we can use again lcd.print to add text or, in our case, the value of a potentiometer we are reading

    Then from here, you can modify the code as you want to read any sensor you like, as long as the sensor gives out a number or text that can be ready by arduino, you will be able to send it to the LCD, in the case it's something that changes, you will want to put it in the loop, and if you just want to read it on start up, you will put it in the set up