Shop OBEX P1 Docs P2 Docs Learn Events
LCD Backlight Time-out — Parallax Forums

LCD Backlight Time-out

FalconFalcon Posts: 191
edited 2008-08-10 23:38 in BASIC Stamp
Hello,·I'm new to the forum and am working on my first BS2 project using an LCD.

The project is a thermostat with several pushbuttons to set the desired temperature.· I bought the 2x16 serial LCD from Parallax and have it working.· My problem is the backlighting.· The project will be powered by a 9v battery so I need the backlight to remain off unless a pushbutton is pushed, then come on for only a preset time after a pushbutton is pressed.· I've determined that a pause will not let any other program activity occur so that won't work.

How else can I accomplish the backlight time-out?

Thanks,

Falcon

·

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-08-10 15:23
    There are command characters (see page 8 of the documentation) you can send to the display to turn the backlight on and off. Whenever you update the display, you would send a "backlight on" character to the display. While your program is waiting for a button to be pushed your program would use a short PAUSE (like 1/10 of a second ... fast enough so a user wouldn't notice, yet substantial), you will decrement a "timeout" counter. When that counter goes to zero, your program will send a "backlight off" character to the display. Whenever the user pushes a button, the counter would be reset to the time-out interval. This time-out won't be exact since there's no direct clock for the Stamp, but it's close enough for this purpose.
  • SRLMSRLM Posts: 5,045
    edited 2008-08-10 18:46
    You'll probably want to use a pause statement of a small value, like 1 or 2. Otherwise, if you use 100 (1/10 second) then the user may push the button very fast and the press isn't registered.
  • FalconFalcon Posts: 191
    edited 2008-08-10 23:38
    Well, that worked like a charm. Don't know why I didn't think of it myself.

    I appreciate the replies.

    Falcon
Sign In or Register to comment.