Skip to content

Instantly share code, notes, and snippets.

@e-Gizmo
Last active November 16, 2018 06:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save e-Gizmo/5828a74a0ad8bd7c4b7d1d7f0ab8c126 to your computer and use it in GitHub Desktop.
Save e-Gizmo/5828a74a0ad8bd7c4b7d1d7f0ab8c126 to your computer and use it in GitHub Desktop.
Sample codes for JM162B I2C LCD module
/*
I2C Serial Interface LCD Module Display
Sample code
*/
#include <Wire.h>
// Get the LCD I2C Library here:
// https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads
// Move any other LCD libraries to another folder or delete them
// See Library "Docs" folder for possible commands etc.
#include <LiquidCrystal_I2C.h>
// set the LCD address to 0x27 for a 16 chars 2 line display
// A FEW use address 0x3F
// Set the pins on the I2C chip used for LCD connections:
// addr, en,rw,rs,d4,d5,d6,d7,bl,blpol
LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Set the LCD I2C address
//LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
void setup(){
Serial.begin(9600);
lcd.begin(16,2); // initialize the lcd for 16 chars 2 lines, turn on backlight
for(int i = 0; i< 3; i++)
{
lcd.backlight();
delay(250);
lcd.noBacklight();
delay(250);
}
lcd.backlight();
lcd.setCursor(0,0); //Start at character 4 on line 0
lcd.print("Hello, world!");
delay(1000);
lcd.setCursor(0,1);
lcd.print("I2C Module Disp");
delay(8000);
lcd.clear();
lcd.setCursor(0,0); //Start at character 0 on line 0
lcd.print("Use Serial Mon");
lcd.setCursor(0,1);
lcd.print("Type to display");
}
void loop()
{
{
if (Serial.available()) {
delay(100);
lcd.clear();
while (Serial.available() > 0) {
lcd.write(Serial.read());
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment