Adding an LCD screen to the water meter

You can add an LCD screen to your newly built water meter to display readings, rather than displaying them on the Arduino serial monitor. You can then disconnect your water meter from the computer after uploading the sketch on to your Arduino.

Using a Hitachi HD44780 driver compatible LCD screen and Arduino Liquid Crystal library, you can easily integrate it with your water meter. Typically, this type of LCD screen has 16 interface connectors. The display has two rows and 16 columns, so each row can display up to 16 characters.

The following image represents the top view of a Hitachi HD44760 driver compatible LCD screen. Note that the 16-pin header is soldered to the PCB to easily connect it with a breadboard.

Adding an LCD screen to the water meter

Hitachi HD44780 driver compatible LCD screen (16 x 2)—Top View

The following image represents the bottom view of the LCD screen. Again, you can see the soldered 16-pin header.

Adding an LCD screen to the water meter

Hitachi HD44780 driver compatible LCD screen (16x2)—Bottom View

Wire your LCD screen with Arduino as shown in the next diagram. Use the 10k potentiometer to control the contrast of the LCD screen. Now, perform the following steps to connect your LCD screen with your Arduino:

  1. LCD RS pin (pin number 4 from left) to Arduino digital pin 8.
  2. LCD ENABLE pin (pin number 6 from left) to Arduino digital pin 7.
  3. LCD READ/WRITE pin (pin number 5 from left) to Arduino GND.
  4. LCD DB4 pin (pin number 11 from left) to Arduino digital pin 6.
  5. LCD DB5 pin (pin number 12 from left) to Arduino digital pin 5.
  6. LCD DB6 pin (pin number 13 from left) to Arduino digital pin 4.
  7. LCD DB7 pin (pin number 14 from left) to Arduino digital pin 3.
  8. Wire a 10K pot between Arduino +5V and GND, and wire its wiper (center pin) to LCD screen V0 pin (pin number 3 from left).
  9. LCD GND pin (pin number 1 from left) to Arduino GND.
  10. LCD +5V pin (pin number 2 from left) to Arduino 5V pin.
  11. LCD Backlight Power pin (pin number 15 from left) to Arduino 5V pin.
  12. LCD Backlight GND pin (pin number 16 from left) to Arduino GND.
    Adding an LCD screen to the water meter

    Fritzing representation of the circuit

  13. Open a new Arduino IDE and copy the sketch named B04844_03_04.ino from the Chapter 3 sample code folder.
  14. First initialize the Liquid Crystal library using following line:
    #include <LiquidCrystal.h>
  15. To create a new LCD object with following parameters, the syntax is LiquidCrystal lcd (RS, ENABLE, DB4, DB5, DB6, DB7):
    LiquidCrystal lcd(8, 7, 6, 5, 4, 3);
  16. Then initialize number of rows and columns in the LCD. Syntax is lcd.begin(number_of_columns, number_of_rows):
    lcd.begin(16, 2);
  17. You can set the starting location to print a text on the LCD screen using following function, syntax is lcd.setCursor(column, row):
    lcd.setCursor(7, 1);

    Note

    Note that the column and row numbers are 0 index based and the following line will start to print a text in the intersection of the 8th column and 2nd row.

  18. Then, use the lcd.print() function to print some text on the LCD screen:
    lcd.print(" ml/s");
  19. Verify and upload the sketch on the Arduino board.
  20. Blow some air through the water flow sensor using your mouth.

You can see some information on the LCD screen such as pulses per second, water flow rate, and total water volume from the beginning of the time:

Adding an LCD screen to the water meter

LCD screen output

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.17.154.139