B4R Library LiquidCrystal_I2C

thedeadhand

Member
Licensed User
example code for new people
B4X:
#Region Project Attributes
    #AutoFlushLogs: True
    #CheckArrayBounds: True
    #StackBufferSize: 300
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'Public variables can be accessed from all modules.
    Public Serial1 As Serial
    Private lcd As LiquidCrystal_I2C
End Sub

Private Sub AppStart
       Serial1.Initialize(115200)
   Log("AppStart")
   lcd.Initialize(0x3F, 16, 2) 'based on the example from the project.
   lcd.Backlight = True
   lcd.Write("test") 
End Sub
 

thedeadhand

Member
Licensed User
0x3f is the address of the screen I have. I'm using a proto board that had i2c pins built in I will try to find what pins they corelate too
 

thedeadhand

Member
Licensed User
i would recommend trying it in the arduino ide first to make sure everthing is working. Also make sure there is a gap between the i2c controller and the lcd because the manufacturer has them touching often, this causes a short and your screen will not work. here is the arduino code for the arduino ide.

B4X:
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>
// Define I2C Address where the PCF8574* is
#define I2C_ADDR    0x3F
// Define LCD Pins
#define BACKLIGHT_PIN     3
#define En_pin  2
#define Rw_pin  1
#define Rs_pin  0
#define D4_pin  4
#define D5_pin  5
#define D6_pin  6
#define D7_pin  7
// Initialize LiquadCrystal with pin setup
LiquidCrystal_I2C lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);
void setup()
{
  // Setup for LCD width and lines
  lcd.begin (16,2);
  // Switch on the backlight
  lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
  lcd.setBacklight(HIGH);
  // Reset cursor to home
  lcd.home (); 
 
        // Print Hello World
  lcd.print("hello");
//lcd.setCursor(0, 2);
//lcd.print("world");
//delay(1000);
//lcd.clear();

                      // Print Hello World

}
void loop()
{

  for (int positionCounter = 0; positionCounter < 16; positionCounter++) {
    // scroll one position left:
    lcd.scrollDisplayLeft();
    // wait a bit:
    delay(150);
  }
}
 

Beja

Expert
Licensed User
Hi Erel
Yesterday I bought an LCD screen (16x2) but it only had the store's product code.. please see the images below and see if it's the same as DFRobot I2C LCD.
Thanks in advance

LCD2.png


LCD1.png
 
Last edited:

Beja

Expert
Licensed User
Thanks atiaust
then I bought the wrong one.. do you know the number of this one and from where I can order it?

thanks again
 

atiaust

Active Member
Licensed User
Beja,

I bought it on ebay. There is numerous suppliers.

Search "Arduino I2C LCD 16x2 Display" or similar and you should find it.

Geoff
 

Beja

Expert
Licensed User
Hi derez
Thanks and I see the connection from the i2c adapter to Arduino, but how the i2c is connected to the LCD board? in #14 I see they are just put next to each other and no connections.
 

derez

Expert
Licensed User
The connection between the LCD and the I2C board is by puting both on the yellow breadboard, connecting all the pins one to one.
Your solution without the I2C is possible but is using almost all the pins in the Arduino.
 
Top