Here is some code (an Arduino sketch) to display a counter on the LCM1602C.
It includes comments and variable names with pin assignment to capture the spec info.
For example:
int lcd6E = 9, // Arduino Pin 9. LCD H/L Enable.
This is for the lcd pin 6 (Enable) to be connected to pin 9 on the Arduino.
Change the Arduino Pin to whatever suits you and use"
LiquidCrystal lcd(lcd4RS, lcd6E, lcd11D4, lcd12D5, lcd13D6, lcd14D7);
Here is the complete code:
/* LED Hello (Notepad).txt
Display Library is here: LiquidCrystal Arduino Library, using small character LCD modules with Teensy
Most LCDs run on 5 volts, but are able to receive
3.3 volt signals from Teensy 3.0 or Teensy 2.0 modified
for 3.3 volts.
LiquidCrystal lcd(RS, Enable, D4, D5, D6, D7)
Create the LiquidCrystal object and specify the 6 pins where the LCD is connected. You can connect more than one display (each to its own pins) and create a separate LiquidCrystal objects for each.
lcd.begin(width, height);
Initialize the display and set the size.
lcd.print(anything);
Print a number or text. This works the same as Serial.print(), but prints to the LCD.
lcd.setCursor(x, y);
Move the cursor to position (x, y). These are zero-based coordinates.
*/
// include the library code:
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
// LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
// LiquidCrystal lcd( RS, E, D4, D5, D6, D7);
int lcd4RS = 10, // Arduino Pin 10. LCD pin 4 is RS.
lcd6E = 9, // Arduino Pin 9. LCD H/L Enable.
lcd11D4 = 5, // Arduino Pin 5.
lcd12D5 = 4, // Arduino Pin 4.
lcd13D6 = 3, // Arduino Pin 3.
lcd14D7 = 2; // Arduino Pin 2.
LiquidCrystal lcd(lcd4RS, lcd6E, lcd11D4, lcd12D5, lcd13D6, lcd14D7);
int potOut;
void setup() {
Serial.begin(9600);
// set up the LCD's number of rows and columns:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.setCursor(0, 0);
lcd.print("hello, world!");
Serial.println("Welcome to Lesson 19: LED Proof.");
}
void loop() {
potOut = analogRead(A5); // Values of 0-1023.
Serial.print(millis()/1000.);
Serial.print(" Pot Output = "); Serial.println(potOut);
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0, 1);
// print the number of seconds since reset:
lcd.print(millis()/1000);
delay(1000);
}
/*
My display is LCD LCM1602C.
*/
I hope this help you with the display and with coding techniques to make it readable.
Malcolm