switimira
Member level 1
menu selection help
hello, currently we are doing a wireless sensor network using xbee. The Rx and Tx is already succeeded. Right now we're working on how to do a menu selection with lcd display. The execution happen only once and then it stop. We seem to not know what is the problem happen whether the hardware or the programming itself.Here i attach the coding..maybe someone could help me with this. Thank you
hello, currently we are doing a wireless sensor network using xbee. The Rx and Tx is already succeeded. Right now we're working on how to do a menu selection with lcd display. The execution happen only once and then it stop. We seem to not know what is the problem happen whether the hardware or the programming itself.Here i attach the coding..maybe someone could help me with this. Thank you
Code:
@ DEVICE HS_OSC
define OSC 20
DEFINE LCD4X20 1
DEFINE LCD_DREG PORTB
DEFINE LCD_DBIT 4
DEFINE LCD_RSREG PORTC
DEFINE LCD_RSBIT 0
DEFINE LCD_EREG PORTC
DEFINE LCD_EBIT 1
DEFINE LCD_BITS 4
DEFINE LCD_LINES 4
DEFINE LCD_COMMANDUS 2000
DEFINE LCD_DATAUS 50
dta var word
input portB.1
ANSEL = 0 'All Digital, konfigurasi ini utk jadikan semua port
ANSELH = 0
push var byte : push = 0
goto screen0
main:
if portB.1=1 then 'arrow down
push = push+1 : goto selection : endif
'if portA.1=1 then 'arrow up
'push = push-1 : goto selection : endif
pause 50
goto main
selection:
pause 200
if push=1 then screen1
if push=2 then screen2
if push=3 then screen3
if push=4 then screen4
if push=5 then screen5
if push=6 then screen6
if push=7 then screen7
if push=8 then screen8
if push=9 then screen9
if push=10 then
push = 1 : goto screen1 : endif
'if push=0 then
'push = 8 : goto screen8 : endif
goto main
screen0:
LCDOUT $FE,1, "|Mode1| |Mode5|"
LCDOUT $FE,$C0+1, "|Mode2| |Mode6|"
LCDOUT $FE,$94+1, "|Mode3| |Mode7|"
LCDOUT $FE,$D4+1, "|Mode4| |Mode8|"
goto main
screen1:
LCDOUT $FE,1,$7E, "|Mode1| |Mode5|"
LCDOUT $FE,$C0+1, "|Mode2| |Mode6|"
LCDOUT $FE,$94+1, "|Mode3| |Mode7|"
LCDOUT $FE,$D4+1, "|Mode4| |Mode8|"
serout2 portc.5,16468,["testing.....",34,13,26]
pause 200
goto main
screen2:
LCDOUT $FE,1, "|Mode1| |Mode5|"
LCDOUT $FE,$C0,$7E, "|Mode2| |Mode6|"
LCDOUT $FE,$94+1, "|Mode3| |Mode7|"
LCDOUT $FE,$D4+1, "|Mode4| |Mode8|"
serout2 portC.5, 16468,["SELAMAT DATANG KE CEDEC...:",34,13,26]
'LCDOUT $FE,1,"SELAMAT DATANG KE CEDEC....:"
PAUSE 100
goto main
screen3:
LCDOUT $FE,1, "|Mode1| |Mode5|"
LCDOUT $FE,$C0+1, "|Mode2| |Mode6|"
LCDOUT $FE,$94,$7E, "|Mode3| |Mode7|"
LCDOUT $FE,$D4+1, "|Mode4| |Mode8|"
'low portb.0 'led off bila arrow ad kat mode 2 LCD
goSUB temp
goto main
temp:'high portb.0
'pause 50
serin2 portc.7,84,[wait("z"),dta(0),DTA(1),DTA(2),DTA(3),DTA(4),DTA(5),DTA(6),DTA(7),DTA(8),dta(9),dta(10),dta(11),dta(12),DTA(13),DTA(14),DTA(15)]
pause 50
serout2 portc.5,16468,[dta(0),DTA(1),DTA(2),DTA(3),DTA(4),DTA(5),DTA(6),DTA(7),DTA(8),dta(9),dta(10),dta(11),dta(12),DTA(13),DTA(14),DTA(15),13]
'LCDOUT $FE,1,dta(0),DTA(1),DTA(2),DTA(3),DTA(4),DTA(5),DTA(6),DTA(7),DTA(8),dta(9),dta(10),dta(11),dta(12),DTA(13),DTA(14),DTA(15)
'low portb.0
return
screen4:
LCDOUT $FE,1, "|Mode1| |Mode5|"
LCDOUT $FE,$C0+1, "|Mode2| |Mode6|"
LCDOUT $FE,$94+1, "|Mode3| |Mode7|"
LCDOUT $FE,$D4,$7E,"|Mode4| |Mode8|"
' high portb.0 'led on bila arrow kat mode 3 LCD
goto main
screen5:
LCDOUT $FE,1, " |Mode1| |Mode5|"
LCDOUT $FE,$C0+1, "|Mode2| |Mode6|"
LCDOUT $FE,$94+1, "|Mode3| |Mode7|"
LCDOUT $FE,$D4,$7E,"|Mode4| |Mode8|"
goto main
screen6:
LCDOUT $FE,1, " |Mode1| ",$7E,"|Mode5|"
LCDOUT $FE,$C0+1, "|Mode2| |Mode6|"
LCDOUT $FE,$94+1, "|Mode3| |Mode7|"
LCDOUT $FE,$D4+1, "|Mode4| |Mode8|"
goto main
screen7:
LCDOUT $FE,1, " |Mode1| |Mode5|"
LCDOUT $FE,$C0+1, "|Mode2| ",$7E,"|Mode6|"
LCDOUT $FE,$94+1, "|Mode3| |Mode7|"
LCDOUT $FE,$D4+1, "|Mode4| |Mode8|"
goto main
screen8:
LCDOUT $FE,1, " |Mode1| |Mode5|"
LCDOUT $FE,$C0+1, "|Mode2| |Mode6|"
LCDOUT $FE,$94+1, "|Mode3| ",$7E,"|Mode7|"
LCDOUT $FE,$D4+1, "|Mode4| |Mode8|"
goto main
screen9:
LCDOUT $FE,1, " |Mode1| |Mode5|"
LCDOUT $FE,$C0+1, "|Mode2| |Mode6|"
LCDOUT $FE,$94+1, "|Mode3| |Mode7|"
LCDOUT $FE,$D4+1, "|Mode4| ",$7E,"|Mode8|"
goto main