Menu

I2C LCD

Help
viscomjim
2015-02-05
2022-06-07
  • viscomjim

    viscomjim - 2015-02-05

    There are LCD displays (1602, 2004) that can be purchased with a small board that connects to the displays pins and allows for communication using I2C.

    http://www.sainsmart.com/sainsmart-iic-i2c-twi-serial-2004-20x4-lcd-module-shield-for-arduino-uno-mega-r3.html

    Looking through the online help, and searching this forum I couldn't find any examples of using these with GCB. Has anyone had any success with these modules? These would be great for low pin count pics using I2C only.

    Any help or steering in the right direction would be greatly appreciated!!!!

     
  • Anobium

    Anobium - 2015-02-05

    I have seen a few questions on this but no code.

    A few thoughts.

    1. Purchase two. Send me one and I will write the demonstration code. This device is i2c - that is supported and the I can use port a LCD driver.
    2. Use the current two-wire LCD solution. Not I2C but driven via another ic - very simple.
    3. Use a one-wire LCD solution. This use serial to drive the LCD via a second GCB chip. Simple and you get to understand the code from end to end.

    Some thoughts.

     
  • viscomjim

    viscomjim - 2015-02-05

    Hi Anobium, I have a couple of these, and would be happy to send to you. Can you get me your address and I will ship them today! Thanks for your help on this!!!

     
  • David Stephenson

    I wrote some code for a Midas COG display (from rapid electronics).
    The main thing is you have to look at the datasheet as displays will have different codes to go into command and data modes and they should all have different id codes (so you can have more than one device on the same pins). You also need pull-ups on the clock and data pins (10k).

    ~~~~~~~~~

    chip 12F683,1

    config OSC=INTosc, MCLRE=Off, WDT=on, boren=off

    'I2C settings

    define I2C_MODE Master

    define I2C_DATA GPIO.2

    define I2C_CLOCK GPIO.1

    wait 200 ms

    SL=0x7C 'DISPLAY ID
    COMSEND=0x00 'display COMMAND send
    DS=0X40 'display DATA send

    'LCD INITIALIZATION
    I2CStart
    I2CSEND(Sl)
    I2CSEND(Comsend)
    I2CSEND(0x34) 'initialize 16x2
    'i2csend(0x38) '16x1
    I2CSEND(COMSEND)
    I2CSEND(0x35)
    'i2csend(0x39)
    I2CSEND(0x14) 'osc
    I2CSEND(0x74) 'contrast
    I2CSEND(0x54) 'pwr
    I2CSEND(0x6F) 'follower
    'WAIT 30 US
    I2CSEND(0x0C) 'on/off
    I2CSEND(0x01) 'clear
    I2Cstop
    'initialization end
    do

    z1=1:z2=2:z3=3:z4=4:z5=5:z6=6

    'send some output to lcd
    I2CStart
    I2CSEND(Sl) 'device id
    I2CSEND(Comsend) 'command mode
    i2csend(0x01) 'clear screen
    i2cstop
    I2CStart
    I2Csend(Sl) 'device id
    I2Csend(DS) 'data mode

    I2CSend (z1+48)
    I2CSend (z2+48) 
    I2CSend (z3+48)
    I2CSend (z4+48)
    I2CSend (z5+48) 
    I2CSend (z6+48)
    

    i2csend(32)
    i2csend(80)
    i2csend(97)

    i2cstop
    sleep
    sleep
    loop
    ~~~~~~~~~~~~~~

     
    • Anobium

      Anobium - 2015-05-22

      Can let me know the part number of the display. Midas will send me a part but I need to know the part number - this looks like a cool addition to the LCD driver set.

       
  • lhatch

    lhatch - 2015-05-22

    I have the same display and want to get it running on an Arduino. Wasted a lot of time and no luck. I took the sample code, changed the config. Had CLK DATA GND and VCC. Nothing

    So I would like to see what Anobium comes up with too.

     
  • Anobium

    Anobium - 2015-05-22

    @lhatch. Should not be to hard. If you have one and are willing to send to me I can integrate in the existing LCD routines. I will also contact the UK supplier and see if they will let me have a sample. If you send me a personal message then we can exchange details etc.

     
  • William Roth

    William Roth - 2015-05-22

    I see no reason that the SainSmart display will not work with the current GCB/LCD.H driver. The I2C adapter uses the PCF8574 I/O expander which is supported by LCD.H.The LCD module seems to be a generic parallel type.

    SainSmart publishes the I2C Address as 0x3F. This is the 7-bit address. The 8-bit address will therefore be 0x7E. This is the address to use in GCB. This address is only possible with the PCF8574A. Look at the chip on the expander board is it a PCF8574T or PCF8574AT? Only the AT Version should support an address of 0x7E. However, if the chip is a knockoff or counterfeit of a real NXP PCF8574AT, then the marking may not matter.

    One thing about these White-on-Blue displays is that the back light must be on and the contrast must be correctly adjusted before you can see any characters. Since SainSmart does not seem to believe in datasheets there is no way to tell if the transistor that drives the back light is an NPN or PNP except by visual inspection or testing. This means you may have to reverse the back light ON/OFF bits.

    When asking for help it is generally a good idea to post your non-working code, so that others might be better able to help.

    I have a similar display but with a different address. It works fine on an UNO R3 with GCB. Here is some working test code but with a different address. Change the address to 0x7E for the SainSmart.

    #chip mega328p, 16
    #config mclr_on
    
    HI2CMode Master
    #define HI2C_DATA
    
    #define LCD_IO 10
    #define LCD_I2C_Address 0x4E      '// Change to 0xFE for SainSmart
    
    #define LCD_Backlight_On_State  1  '// These may need to be reversed
    #define LCD_Backlight_Off_State 0
    
    do
       CLS
       wait 1 s
       Locate 0,0
       PRINT "Great Cow Basic .94"
       Locate 1,0
       Print "Arduino UNO ": Print chipnamestr
       Locate 2,0
       PRINT "I2C LCD Driver"
       wait 1 s
    loop
    
     

    Last edit: William Roth 2015-05-22
  • lhatch

    lhatch - 2015-05-22

    Hey Evan,

    I assume the other fellow did not send one. Might be easier if I send a link to the actual part and paypal (if you have paypal) the cash and you pick one up other there. The International shipping might cost more than the part lol.

    How do I PM here, I clicked your name but did not see a PM button.

    Thanks again.

     
  • lhatch

    lhatch - 2015-05-22

    No I have the same one sainsmart is, and figured is should work. But I just ran William's program and it works fine. So all is good. To simple to be wiring, so I must have missed something when I ran the sample code.

    Thanks again guys. And speacial thanks to William, I am off and running. I have a starting point now. I think I can change a mode number at get the display without the 1C2/twi module (I loose more I/O pins though) and it will work as well. Is that correct?

     

Log in to post a comment.