Displaying Sensor Values on LCD

Displaying Sensor Values on LCD © GPL3+

This project will show how to set up a 16 x 2 LCD screen and display multiple sensor values.

  • 63,247 views
  • 6 comments
  • 44 respects

Components and supplies

Apps and online services

About this project

I have been tinkering with Arduino for a while now, mostly with LED's and stuff and finally bought my first LCD and decided to test it with one sensor which worked fine, however I found very little projects where it shows multiple sensors being used so I decided to build this one.

This project uses 2 potentiometers that are connected on a breadboard to an Arduino and LCD. The end result is that the LCD should indicate the values of both the potentiometers when they are adjusted.

The Liquid Crystal Display

Before starting the configuration, let's look and the LCD closely and see what the 16 pins are for:

  • GND - Ground Connection
  • VCC - +5V Connection
  • VO - analogue pin used for screen brightness, connects to Potentiometer.
  • RS - tells the LCD what will be written to it.
  • R/W - the read/write pin (normally hardwired to ground).
  • E - tells the LCD the data is ready to be written.
  • D0 to D7 - bus lines for the LCD, this is where your data is passed from the Arduino to the LCD.
  • A - +5V Connection for the backlight of the LCD.
  • K - the ground pin for the backlight of the LCD.

Wiring

Now we can start making connections on and to the breadboard. Below is a step-by-step guide:

  • Connect the 10K Ohm potentiometer (this potentiometer is used to control the contrast of the LCD). The middle pin of potentiometer is connected to the VO pin and the other two wires are connected to +5V and ground on the breadboard.
  • Connect pin-A to the +5V and pin-K to ground on the breadboard.
  • Connect pin-D7 to digital pin 12, pin-D6 to digital pin 11, pin-D5 to digital pin 10 and pin-D4 to digital pin 9. (Digital pins on the Arduino).
  • Connect pin-RS to digital pin 7 on the Arduino.
  • Connect pin-RW to ground on the breadboard.
  • Connect pin-VSS to ground on the breadboard.
  • Connect pin-VDD to +5V on the breadboard.
  • Connect pin-E to digital pin 8 on the Arduino.
  • Place the first potentiometer on the board and connect the center pin to Analog Pin 1 on the Arduino and the other pins to ground and +5V on the breadboard.
  • Place the second potentiometer on the board and connect the center pin to Analog Pin 2 on the Arduino and the other pins to ground and +5V on the breadboard.

See the picture below for the potentiometers that are to be used.

Code

Upload the code below to your Arduino and adjust your potentiometers as you wish. The LCD display will show 2 lines with the values of the potentiometers. You can adjust the B10K potentiometer to ensure the contrast of the LCD is perfect to read the values.

And that's it! Thank you for checking out my project and please feel free to comment on how I can make it more useful.

Code

The Software partArduino
The software will communicate with the LCD and the analog pins of the Arduino. Because we use the LiquidCrystal library, we don't have to communicate with the digital pins.
// include the library code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(7,8,9,10,11,12);

int potPin1 = A1;
int potPin2 = A2;

void setup()
{
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
lcd.clear();

pinMode(potPin1, INPUT);
pinMode(potPin2, INPUT);
}

void loop()
{
lcd.setCursor(0,0); // Sets the cursor to col 0 and row 0
lcd.print("SensorVal1: "); // Prints Sensor Val: to LCD
lcd.print(analogRead(potPin1)); // Prints value on Potpin1 to LCD
lcd.setCursor(0,1); // Sets the cursor to col 1 and row 0
lcd.print("SensorVal2: "); // Prints Sensor Val: to LCD
lcd.print(analogRead(potPin2)); // Prints value on Potpin1 to LCD
}

Schematics

Wiring Diagram
I did not have enough orange wire so used blue instead, however I made the 4 wires for data orange in the sketch.
Mmvuepupwqfzebzeouhc

Comments

Similar projects you might like

Sound Sensor Activated LEDs with LCD for Sound Level Data!

Project tutorial by Heathen_Hacks-v2

  • 1,410 views
  • 2 comments
  • 8 respects

LCD (Liquid Crystal Display)

by MicroBob

  • 30,778 views
  • 40 comments
  • 101 respects

Soil Moisture Sensor With LCD Display

Project tutorial by Patel Darshil

  • 19,347 views
  • 4 comments
  • 37 respects

DHT11 Humidity + Temperature Sensor with 16x2 LCD display

Project showcase by onatto22

  • 9,123 views
  • 1 comment
  • 17 respects

Portable Arduino Temp/Humidity Sensor with LCD

Project tutorial by ThothLoki

  • 153,387 views
  • 115 comments
  • 186 respects

Ultrasonic Sensor with Alarm, LCD and Temperature

Project tutorial by MichDragstar

  • 4,645 views
  • 7 comments
  • 19 respects
Add projectSign up / Login