Controlling LCD B/L


Closed Thread
Results 1 to 14 of 14

Hybrid View

  1. #1
    Join Date
    Jan 2009
    Posts
    4

    Default Controlling LCD B/L

    Code:
    @ DEVICE pic16F876              ' System Device	
    @ DEVICE pic16F876, WDT_ON      ' Watchdog Timer
    @ DEVICE pic16F876, PWRT_ON     ' Power-On Timer
    @ DEVICE pic16F876, BOD_ON      ' Brown-Out Detect
    @ DEVICE pic16F876, LVP_OFF     ' Low-Voltage Programming
    @ DEVICE pic16F876, CPD_OFF     ' Data Memory Code Protect
    @ DEVICE pic16F876, PROTECT_OFF ' Program Code Protection
    @ DEVICE pic16F876, XT_OSC
    ADCON1=7
    ON INTERRUPT GOTO KESME
    INTCON = %11110000 ' Tmr0 aktif 
    OPTION_REG = %01010101'Pull up dirençleri İPTAL- Bölme oranı 1/64.
    
    Define LCD_DREG      PORTC ' LCD data portunu belirle 
    Define LCD_DBIT      4 ' 4 bit'lik veri yolu 
    Define LCD_RSREG     PORTC ' LCD register seçme portunu belirle 
    Define LCD_RSBIT     2 ' LCD register seçme bitini belirle 
    Define LCD_EREG      PORTC ' LCD enable portunu belirle 
    Define LCD_EBIT      3 ' LCD enable bitini belirle 
    Define LCD_LINES     2 ' LCD'deki satir sayisi
    trisb=%11111111
    TRISC=%11111101
    
    
    LCDK VAR BYTE
    Z VAR BYTE
    Led_isik VAR BYTE
    SAYAC VAR BYTE
    LCD_Led VAR PORTC.1 
    'tmr0=0 
    Lcdk=0
    BASLA:
    PAUSE 300
    LCDOUT $FE,$80,"HI!"
    LCDOUT $FE,$C0,"LCD BACK LIGHT CONT."
    LCDOUT $FE,$94,"B.0 & TMR0"
    
    DISABLE 
    KESME: 
    if INTCON.1=1 then 
    z=1 
    Led_isik=0 
    SAYAC=0  
    Lcdk=0 
    endif 
    if z=1 then 
    if Lcdk=0 then 
    LCD_Led=1 
    Lcdk=1 
    endif 
    SAYAC=SAYAC+1 
    if SAYAC=62 then 
    SAYAC=0 
    Led_isik= Led_isik +1 
    endif 
    if Led_isik=8 then 
    LCD_LED=0 
    Led_isik=0 
    SAYAC=0 
    Z=0 
    Lcdk=0 
    endif 
    endif
    RESUME 
    ENABLE
    END
    Hi I want to control LCD B/L with B.0 and Tmr0 interrupts. But still some problems. I can't find it. Pls Help me !!

  2. #2
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    The backlight of an LCD generally cannot be controlled through the digital interface.

    You will need a FET (I use an FDC610) with the source connected to GND, the drain connected to the backlight (-) terminal, and the backlight (+) terminal connected to 5V. Your LCD may require a 5 ohm .5W resistor between the (+) terminal and 5V to limit the backlight current (check the datasheet).

    Connect a 10K resistor between the FET gate and GND and also connect
    the gate to a PIC output pin. Whenever you want to turn on the backlight, bring the output pin high.
    Charles Linquist

  3. #3
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

  4. #4
    Join Date
    Jan 2009
    Posts
    4


    Did you find this post helpful? Yes | No

    Default

    Hi Melanie,
    Do I have to use pwm for lcd lihgt ?

  5. #5
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,648


    Did you find this post helpful? Yes | No

    Wink Which Goal ???

    Hi,

    As I do not understand your comments and variables ( Turkish ??? )

    One good question would be :

    What do you want to do ???

    - on/off control ??
    - dimmer ??

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  6. #6
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    Well, you don't have to use PWM... but if you do, then you will have control over the Brightness and will be able to adjust for your own comfort level. If you have two PWM channels available, then you can do the same thing for your LCD's Contrast. Search the forum for Easy Contrast if you want to do that.

    If you just want to turn your LCD's Backlight ON/OFF then any I/O Channel will do, but you must know how much current the Backlight will require... if it requires more than 25mA, then you need an external Driver of some sort.

Similar Threads

  1. Is this code not initialising the LCD properly?
    By Platypus in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 30th January 2010, 19:14
  2. 16f688 LCD what have I done wrong
    By spitfiredriver in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 8th August 2009, 19:54
  3. LCD Problem
    By karenhornby in forum General
    Replies: 3
    Last Post: - 19th June 2008, 11:43
  4. LCD will not start
    By btaylor in forum mel PIC BASIC Pro
    Replies: 49
    Last Post: - 24th May 2007, 02:30
  5. Dedicated LCD Controller question
    By chuckles in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 27th February 2006, 14:44

Members who have read this thread : 0

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