Jųan
- 4th August 2005, 10:51
How can I rewrite the following code to display the text constantly instead of looping. It blinks because of the pause but if I take the pause off then the timing gets out of wack and the LCD displays funny characters. Also when I switch on the circuit, the LCD displays "pressed" for a few cycles before going back to "press button" mode. Basically I would like the "press button" constantly without blinking until the button is pressed and then to display "button pressed" without blinking.
Thanks in advance
Juan
Include "modedefs.bas" ' Include serial modes
DEFINE BUTTON_PAUSE 20 ' button debounce delay is 50ms
TRISA = %00000000 ' All the PORTA pins to outputs.
TRISB = %11111111 ' All the PORTB pins to inputs.
I con 254 '254h = 1111 1110 (Sets LCD to command mode)
ClrScr con 1 '01h = 0000 00001 (Clears Screen & goes to position 1)
Line2 con $C0 'COh = 1100 0000B (sets address to positionn 40 on LCD)
DispCur con 12 '12h = 0000 1100 (activates display & cursor mode)
'Commands obtained from LCD article in epemag.com
pause 400 ' Allow LCD to boot up
LOOP: IF PORTB.2 = 0 THEN
serout PORTA.1,T9600,[I,clrscr]
pause 100
Serout PORTA.1,T9600,["Press Button"]
endif
if PORTB.2 = 1 THEN
serout PORTA.1,T9600,[I,clrscr]
pause 100
SEROUT PORTA.1,T9600,["Button Pressed!"] ' Indicate Button Pressed
endif
goto loop
end
Thanks in advance
Juan
Include "modedefs.bas" ' Include serial modes
DEFINE BUTTON_PAUSE 20 ' button debounce delay is 50ms
TRISA = %00000000 ' All the PORTA pins to outputs.
TRISB = %11111111 ' All the PORTB pins to inputs.
I con 254 '254h = 1111 1110 (Sets LCD to command mode)
ClrScr con 1 '01h = 0000 00001 (Clears Screen & goes to position 1)
Line2 con $C0 'COh = 1100 0000B (sets address to positionn 40 on LCD)
DispCur con 12 '12h = 0000 1100 (activates display & cursor mode)
'Commands obtained from LCD article in epemag.com
pause 400 ' Allow LCD to boot up
LOOP: IF PORTB.2 = 0 THEN
serout PORTA.1,T9600,[I,clrscr]
pause 100
Serout PORTA.1,T9600,["Press Button"]
endif
if PORTB.2 = 1 THEN
serout PORTA.1,T9600,[I,clrscr]
pause 100
SEROUT PORTA.1,T9600,["Button Pressed!"] ' Indicate Button Pressed
endif
goto loop
end