Here I go again :-)
I am trying to display some values on an lcd. One that counts from 10 to 20 using up\down buttons. And when I press RB1 the lcd counts from 80 - 90 using the same up\down. I created the dummy functions because I found that having these allowed me to hold the button and have continous incrementation\decrementation (see code below). Ive connected RA4 and RA1 to ground.
My problem is that I want to solely increment\decrement num2 without interfering with num1. The other problem is that when I press RB1 to go num2 mode, the lcd counts up on its own. If anyone has a look at my grubby code and sees what Im trying to do and where Im doin wrong, can you shead some light please?
Muchas Gracias
Juan
************************************************** ******
Include "modedefs.bas" ' Include serial modes
DEFINE BUTTON_PAUSE 75 ' button debounce delay is 75ms
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 192 '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
B0 var byte
B1 var byte
B2 var byte
B3 var byte
B4 var byte
number var word
number2 var word
B0 = 0
B1 = 0
B2 = 0
B3 = 0
B4 = 0
number = 15
number2 = 85
serout PORTB.0,T9600,[i,clrScr] ' Clearscreen
pause 400
numSetup:
serout PORTB.0,T9600,[I,128,"Display num1"] ' Setup display
serout PORTB.0,T9600,[I,line2," Press button"] ' Setup display
numMain:
pause 25
Button PORTA.7,1,200,255,B0,1,incNum
Button PORTA.6,1,200,255,B1,1,decNum
Button PORTA.4,1,200,255,B0,1,dummy1
Button PORTA.1,1,200,255,B1,1,dummy2
Button PORTB.1,1,200,255,B2,1,number2Setup
Serout PORTB.0,T9600,[i,line2,#number]
goto numMain
incNum:
if number > 19 then numMain
number = number + 1
pause 100
Goto numMain ' goes back to main function
decNum:
if number < 11 then numMain
number = number - 1
pause 100
Goto nummain ' goes back to main function
dummy1:
PAUSE 1000
GOTO nummain
dummy2:
PAUSE 1000
GOTO nummain
number2Setup:
serout PORTB.0,T9600,[i,clrScr] ' Clearscreen
serout PORTB.0,T9600,[I,128,"Display num2"] ' Setup display
number2Main:
pause 25
Button PORTB.7,1,200,255,B3,1,incNumber2
Button PORTA.6,1,200,255,B4,1,decNumber2
Button PORTB.1,1,200,255,B2,1,numsetup
serout PORTB.0,T9600,[I,line2,#number2]
goto number2Main
incNumber2:
if number2 > 89 then number2Main
number2 = number2 + 1
pause 100
Goto number2main
decNumber2:
if number2 < 81 then number2main
number2 = number2 - 1
pause 100
Goto number2main
Bookmarks