B4R Library LiquidCrystal_I2C

Discussion in 'B4R Libraries' started by Erel, May 2, 2016.

  1. Erel

    Erel Administrator Staff Member Licensed User

    Attached Files:

  2. thedeadhand

    thedeadhand Member Licensed User

    example code for new people
    Code:
    #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(
    0x3F162'based on the example from the project.
       lcd.Backlight = True
       lcd.Write(
    "test"
    End Sub
     
    Erel likes this.
  3. cloner7801

    cloner7801 Active Member Licensed User

    what is 0x3F ?
    Help me to connect pins
     
  4. thedeadhand

    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
     
  5. cloner7801

    cloner7801 Active Member Licensed User

    Can you help me to connect my lcd to board?
     
  6. thedeadhand

    thedeadhand Member Licensed User

    Ya sure, you have an i2c controller right? Did it come with the LCD ? Or do you just have an LCD screen?
     
    cloner7801 likes this.
  7. cloner7801

    cloner7801 Active Member Licensed User

    Thanks, Yes! this is with lcd and I have 4pin
     
  8. thedeadhand

    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.

    Code:
    #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(
    02);
    //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);
      }
    }
     
  9. thedeadhand

    thedeadhand Member Licensed User

  10. Beja

    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: Jun 29, 2016
  11. atiaust

    atiaust Active Member Licensed User

    Hi Beja,

    The LCD has a I2C daughter board on the back. See attached image.

    Regards
     

    Attached Files:

    Beja likes this.
  12. Beja

    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
     
  13. Cableguy

    Cableguy Expert Licensed User

    You can use your display, just buy the i2c to serial board
     
    Beja likes this.
  14. derez

    derez Expert Licensed User

    If there are two boards they can be connected like this:
    IMG_20160629_133141.jpg
     
    Peter Simpson and Beja like this.
  15. atiaust

    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 likes this.
  16. Beja

    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.
     
  17. Beja

    Beja Expert Licensed User

    I think I found the solution here.. you even don't need the I2C module.
     
  18. derez

    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.
     
    f0raster0, Beja and Cableguy like this.
  19. Hans- Joachim Krahe

    Hans- Joachim Krahe Active Member Licensed User

    ...probably needs a "delay" after "write" - otherwise there can be a reset...
     
  20. Hans- Joachim Krahe

    Hans- Joachim Krahe Active Member Licensed User

    does this driver use different AnalogPorts with arduino mega too?
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice