hi,
I,ve been working on a nine button touch keypad using an 18m2 which is connected too a serial lcd ( axe133) which is working well.What i would like to do now serialize the key pad so it can comminacte with a 14m2 or any other picaxe i,ve planned to use pins c.2 and c.7 on the 18m2. But am having trouble getting started on the reciever code to decode the button press, could someone please offer advice on how i can do this.
this is the code so far if am going wrong please say
cheers rob
I,ve been working on a nine button touch keypad using an 18m2 which is connected too a serial lcd ( axe133) which is working well.What i would like to do now serialize the key pad so it can comminacte with a 14m2 or any other picaxe i,ve planned to use pins c.2 and c.7 on the 18m2. But am having trouble getting started on the reciever code to decode the button press, could someone please offer advice on how i can do this.
Code:
' serail keypad
'
#picaxe 18m2
#no_data
symbol key1 = b.1
symbol key2 = b.5
symbol key3 = b.4
symbol key4 = c.0
symbol key5 = b.3
symbol key6 = b.6
symbol key7 = c.1
symbol key8 = b.2
symbol key9 = b.7
symbol lcd = c.6
symbol topline = 128
symbol bottomline = 192
symbol abit = 200
symbol abitx= 300
init:
pause abit
serout lcd,n2400,(254,topline," serial keypad ")
serout lcd,n2400,(254,bottomline," WELCOME robert ")
pause abitx
main:
do
'###button1
touch16 key1,w0 ; read value into w0
if w0 > 7200 then
serout lcd,n2400,(254,topline,"hello"," ")
serout lcd,n2400,(254,bottomline,"key one ")
pause abit
gosub send
serout lcd,n2400,(254,bottomline," sent ")
pause abit
else
serout lcd,n2400,(254,1)
end if
'###button2
touch16 key2,w1 ; read value into w0
if w1 > 6300 then
serout lcd,n2400,(254,topline," ")
serout lcd,n2400,(254,bottomline,"key two ")
pause abit
gosub send
serout lcd,n2400,(254,bottomline," sent ")
pause abit
else
serout lcd,n2400,(254,1)
end if
'###button3
touch16 key3,w2 ; read value into w0
if w2 > 6500 then
serout lcd,n2400,(254,topline," ")
serout lcd,n2400,(254,bottomline,"key three ")
pause abit
gosub send
serout lcd,n2400,(254,bottomline," sent ")
pause abit
else
serout lcd,n2400,(254,1)
end if
'###button4
touch16 key4,w3 ; read value into w0
if w3 > 6600 then
serout lcd,n2400,(254,topline,#w3," ")
serout lcd,n2400,(254,bottomline,"key four ")
pause abit
gosub send
serout lcd,n2400,(254,bottomline," sent ")
pause abit
' LED on
else
serout lcd,n2400,(254,1) '
end if
'#####button5
touch16 key5,w4 ; read value into w0
if w4 > 7150 then
serout lcd,n2400,(254,topline," ")
serout lcd,n2400,(254,bottomline,"key five ")
pause abit
gosub send
serout lcd,n2400,(254,bottomline," sent ")
pause abit
' LED on
else
serout lcd,n2400,(254,1)
end if
'####button 6
touch16 key6,w5 ; read value into w0
if w5 > 6400 then
serout lcd,n2400,(254,topline," ")
serout lcd,n2400,(254,bottomline,"key six ")
pause abit
gosub send
serout lcd,n2400,(254,bottomline," sent ")
pause abit
else
serout lcd,n2400,(254,1)
end if
'###button7
touch16 key7,w6 ' read value into w0
if w6 > 6300 then
serout lcd,n2400,(254,topline," ")
serout lcd,n2400,(254,bottomline,"key seven ")
pause abit
gosub send
serout lcd,n2400,(254,bottomline," sent ")
pause abit
else
serout lcd,n2400,(254,1)
end if
'###button8
touch16 key8,w7 ; read value into w0
if w7 > 7150 then
serout lcd,n2400,(254,topline," ")
serout lcd,n2400,(254,bottomline,"key eight ")
pause abit
gosub send
serout lcd,n2400,(254,bottomline," sent ")
pause abit
else
serout lcd,n2400,(254,1)
end if
'button9
touch16 key9,w8 ; read value into w0
if w8 >7800 then
serout lcd,n2400,(254,topline," ")
serout lcd,n2400,(254,bottomline,"key nine ")
pause abit
gosub send
serout lcd,n2400,(254,bottomline," sent ")
pause abit
' LED on
else
serout lcd,n2400,(254,1)
end if
pause 20
loop
send:
pause 10
return
cheers rob