I2C lcd ( arduino ) with PICBASIC, help


Closed Thread
Results 1 to 40 of 93

Hybrid View

  1. #1
    Join Date
    Jun 2008
    Location
    Varese , Italy
    Posts
    326


    Did you find this post helpful? Yes | No

    Default Re: I2C lcd ( arduino ) with PICBASIC, help

    Is there a lista of PICs programmable by PICKIT2 ?
    Thanks
    Ambrogio

  2. #2
    Join Date
    May 2013
    Location
    australia
    Posts
    2,644


    Did you find this post helpful? Yes | No

    Default Re: I2C lcd ( arduino ) with PICBASIC, help

    Quote Originally Posted by iw2fvo View Post
    Is there a lista of PICs programmable by PICKIT2 ?
    not that I can find ,but there is not many that aren't on the supported device list.
    you can download the pickit2 program(its free) from microchip site and check out the supported device list if you have specific devices to check
    http://www.microchip.com/Development...tDocumentation

  3. #3
    Join Date
    Jun 2008
    Location
    Varese , Italy
    Posts
    326


    Did you find this post helpful? Yes | No

    Default Re: I2C lcd ( arduino ) with PICBASIC, help

    Hi Steve,
    I am back again on this LCD ...
    I have repaired the programmer and so I had the occasion to test the program.
    > Back light does not come on at all .
    > nothing is displayed on the LCD
    If you have something more to suggest, I am ready to go on .
    Thanks
    Regards,
    Ambrogio

  4. #4
    Join Date
    Jun 2009
    Location
    Sc*nthorpe, UK
    Posts
    333


    Did you find this post helpful? Yes | No

    Default Re: I2C lcd ( arduino ) with PICBASIC, help

    Quote Originally Posted by iw2fvo View Post
    Hi Steve,
    I am back again on this LCD ...
    I have repaired the programmer and so I had the occasion to test the program.
    > Back light does not come on at all .
    > nothing is displayed on the LCD
    If you have something more to suggest, I am ready to go on .
    Thanks
    Regards,
    Ambrogio
    Not good news then!

    I need to refresh my memory. Post the full code you are using please.

  5. #5
    Join Date
    Jun 2008
    Location
    Varese , Italy
    Posts
    326


    Did you find this post helpful? Yes | No

    Default Re: I2C lcd ( arduino ) with PICBASIC, help

    here it is:

    DEFINE OSC 40 ' 10 MHz XTAL AND X 4 INTERNAL PLL
    DEFINE I2C_SLOW 1
    SDA VAR PORTD.2 ; I2C Data pin
    SCL VAR PORTD.3 ; I2C Clock Pin
    LCD_Addr CON 78
    'LCD_BuffSize CON 30
    'LCD_Buff VAR BYTE[LCD_BuffSize]
    'LCD_BuffAddr CON EXT : @LCD_BuffAddr = _LCD_Buff
    'LCD_BuffLen VAR WORD ; Length of data in buffer
    LCD_Data VAR BYTE ; Data to Send to LCD
    LCD_Byte VAR BYTE ; Nibbles to Send
    LCD_RS VAR LCD_Byte.0 ; Register Select bit
    LCD_RW VAR LCD_Byte.1 ; Read/Write bit
    LCD_E VAR LCD_Byte.2 ; Enable bit
    LCD_BackLight VAR LCD_Byte.3 ; Backlight 0=ON
    LCD_WriteMode VAR BYTE ; 1=LowNibble, 2=HighNibble, 3=Both
    LCD_CommandMode VAR BIT ; Indicates next byte is a command
    LCD_Byte2 VAR BYTE ; Same nibble without E bit
    LCD_Idx VAR BYTE
    testmode var byte



    ;----[Initialize the LCD]-------------------------------------------------------
    PAUSE 250 ; LCD Power-on delay
    LCD_Backlight = 1 ; Backlight OFF
    LCD_RW = 0 ; Write to LCD
    LCD_RS = 0 ; Command Register

    LCD_WriteMode = 1 ;-- Low Nibbles only
    LCD_Data = 3 ; Reset 3 times
    gosub LCD_Write_
    PAUSEUS 6000
    gosub LCD_Write_
    PAUSEUS 1000
    gosub LCD_Write_
    PAUSEUS 1000

    LCD_Data = 2 ; Start 4-bit mode
    gosub LCD_Write_
    PAUSEUS 1000

    LCD_WriteMode = 3 ;-- Both Nibbles
    LCD_Data = $28
    gosub LCD_Write_ ; Function Set, 4-bit, 2-line, 5x7
    LCD_Data = $0C
    gosub LCD_Write_ ; Display ON
    LCD_Data = $01
    gosub LCD_Write_ ; Clear Screen
    PAUSE 2
    LCD_Data = $06
    gosub LCD_Write_ ; Entry Mode

    PAUSE 2 ; Let command finish
    LCD_RS = 1 ' this is data
    goto main

    LCD_WRITE_:
    LCD_E = 1
    IF LCD_WriteMode.1 = 1 THEN ; Write High Nibble
    LCD_Byte = (LCD_Byte & $0F) | (LCD_Data & $F0)
    LCD_Byte2 = LCD_Byte & $FB
    I2CWRITE SDA,SCL, LCD_Addr,[LCD_Byte, LCD_Byte2]
    ENDIF

    IF LCD_WriteMode.0 = 1 THEN ; Write Low Nibble
    LCD_Byte = (LCD_Byte & $0F) | ((LCD_Data << 4 )& $F0)
    LCD_Byte2 = LCD_Byte & $FB
    I2CWRITE SDA,SCL, LCD_Addr,[LCD_Byte, LCD_Byte2]
    ENDIF
    return



    Main:
    LCD_Data = "T"
    gosub LCD_Write_
    LCD_Data = "e"
    gosub LCD_Write_
    LCD_Data = "s"
    gosub LCD_Write_
    LCD_Data = "t"
    gosub LCD_Write_
    goto main

  6. #6
    Join Date
    Jun 2009
    Location
    Sc*nthorpe, UK
    Posts
    333


    Did you find this post helpful? Yes | No

    Default Re: I2C lcd ( arduino ) with PICBASIC, help

    Please use code tags as it is easier for me to read.

  7. #7
    Join Date
    Jun 2009
    Location
    Sc*nthorpe, UK
    Posts
    333


    Did you find this post helpful? Yes | No

    Default Re: I2C lcd ( arduino ) with PICBASIC, help

    Quote Originally Posted by iw2fvo View Post
    here it is:
    Code:
    DEFINE OSC 40 ' 10 MHz XTAL AND X 4 INTERNAL PLL 
    DEFINE I2C_SLOW 1
    SDA         VAR PORTD.2       ; I2C Data pin
    SCL         VAR PORTD.3       ; I2C Clock Pin
    LCD_Addr CON 78
    'LCD_BuffSize    CON 30
    'LCD_Buff        VAR BYTE[LCD_BuffSize]
    'LCD_BuffAddr    CON EXT : @LCD_BuffAddr = _LCD_Buff
    'LCD_BuffLen     VAR WORD        ; Length of data in buffer
    LCD_Data        VAR BYTE        ; Data to Send to LCD
    LCD_Byte        VAR BYTE        ; Nibbles to Send
    LCD_RS          VAR LCD_Byte.0  ; Register Select bit
    LCD_RW          VAR LCD_Byte.1  ; Read/Write bit
    LCD_E           VAR LCD_Byte.2  ; Enable bit
    LCD_BackLight   VAR LCD_Byte.3  ; Backlight 0=ON
    LCD_WriteMode   VAR BYTE        ; 1=LowNibble, 2=HighNibble, 3=Both
    LCD_CommandMode VAR BIT         ; Indicates next byte is a command
    LCD_Byte2       VAR BYTE        ; Same nibble without E bit
    LCD_Idx         VAR BYTE
    testmode        var byte
    
    
    
    ;----[Initialize the LCD]-------------------------------------------------------
    PAUSE 250             ; LCD Power-on delay
    LCD_Backlight = 1     ; Backlight OFF
    LCD_RW = 0            ; Write to LCD
    LCD_RS = 0            ; Command Register
    
    LCD_WriteMode = 1     ;-- Low Nibbles only
    LCD_Data = 3          ; Reset 3 times
    gosub LCD_Write_
    PAUSEUS 6000
    gosub LCD_Write_
    PAUSEUS 1000
    gosub LCD_Write_
    PAUSEUS 1000
    
    LCD_Data = 2          ; Start 4-bit mode
    gosub LCD_Write_
    PAUSEUS 1000
    
    LCD_WriteMode = 3     ;-- Both Nibbles
    LCD_Data = $28
    gosub LCD_Write_      ; Function Set, 4-bit, 2-line, 5x7
    LCD_Data = $0C
    gosub LCD_Write_      ; Display ON
    LCD_Data = $01
    gosub LCD_Write_      ; Clear Screen
    PAUSE 2
    LCD_Data = $06 
    gosub LCD_Write_      ; Entry Mode
                           
    PAUSE 2               ; Let command finish
    LCD_RS = 1   ' this is data
    goto main
    
    LCD_WRITE_:
       LCD_E = 1
       IF LCD_WriteMode.1 = 1 THEN                             ; Write High Nibble
         LCD_Byte = (LCD_Byte & $0F) | (LCD_Data  & $F0)
         LCD_Byte2 = LCD_Byte & $FB    
         I2CWRITE SDA,SCL, LCD_Addr,[LCD_Byte, LCD_Byte2]
       ENDIF
      
       IF LCD_WriteMode.0 = 1 THEN                             ; Write Low Nibble
         LCD_Byte = (LCD_Byte & $0F) | ((LCD_Data << 4 )& $F0)
         LCD_Byte2 = LCD_Byte & $FB
         I2CWRITE SDA,SCL, LCD_Addr,[LCD_Byte, LCD_Byte2]
       ENDIF
    return
    
    
    
    Main:
    LCD_Data = "T"
    gosub LCD_Write_ 
    LCD_Data = "e" 
    gosub LCD_Write_
    LCD_Data = "s" 
    gosub LCD_Write_ 
    LCD_Data = "t" 
    gosub LCD_Write_ 
    goto main
    Need to add pauseus!

    Code:
    Main:
    LCD_Data = "T"
    gosub LCD_Write_: PAUSEUS 50
    LCD_Data = "e" 
    gosub LCD_Write_: PAUSEUS 50
    LCD_Data = "s" 
    gosub LCD_Write_: PAUSEUS 50 
    LCD_Data = "t" 
    gosub LCD_Write_: PAUSEUS 50 
    goto main

  8. #8
    Join Date
    Jun 2009
    Location
    Sc*nthorpe, UK
    Posts
    333


    Did you find this post helpful? Yes | No

    Default Re: I2C lcd ( arduino ) with PICBASIC, help

    And to test backlight is working try

    Code:
    Main:
    LCD_Backlight = 0
    LCD_Data = "T"
    gosub LCD_Write_: PAUSEUS 50
    LCD_Data = "e" 
    gosub LCD_Write_: PAUSEUS 50
    LCD_Data = "s" 
    gosub LCD_Write_: PAUSEUS 50 
    LCD_Data = "t" 
    gosub LCD_Write_: PAUSEUS 50 
    pause 500
    LCD_Backlight = 1
    LCD_Data = "-" 
    gosub LCD_Write_: PAUSEUS 50 
    pause 500
    goto main

Similar Threads

  1. Interfacing with Arduino I2C LCD
    By norohs in forum Documentation
    Replies: 47
    Last Post: - 30th May 2017, 18:53
  2. I2c ext eeprom picbasic
    By iw2fvo in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 16th July 2011, 22:00
  3. How do I operate an Arduino I2C LCD
    By menta in forum General
    Replies: 8
    Last Post: - 13th July 2011, 02:28
  4. Still new to PicBasic - i2c questions
    By cometboy in forum mel PIC BASIC
    Replies: 4
    Last Post: - 13th November 2006, 18:27
  5. A little help with I2C and PICBASIC Pro
    By Qacer in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 24th January 2006, 16:13

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts