ok, so this is the code i have wrote this morning:
Code:
'OUTPUTS
'Row 1 - Blue Wire - Pin 10 (b.4)
'Row 2 - Green Wire - Pin 11 (b.5)
'Row 3 - Yellow Wire - Pin 12 (b.6)
'Row 4 - Brown Wire - Pin 13 (b.7)
'INPUTS
'Column 1 - Red Wire - Pin 17 (C.0)
'Column 2 - Orange Wire - 16 (C.7)
'Column 3 - White Wire - 15 (C.6)
'KeyPad
' 1 2 3
' 4 5 6
' 7 8 9
' * 0 #
symbol Row1 = b.4
symbol Row2 = b.5
symbol Row3 = b.6
symbol Row4 = b.7
symbol Column1 = c.0
symbol Column2 = c.7
symbol Column3 = c.6
symbol PinPressed1 = b0
symbol PinPressed2 = b4
symbol PinPressed3 = b5
symbol PinPressed4 = b6
Symbol Combination = b1
symbol Num1 = 1
symbol Num2 = 128
symbol Num3 = 64
symbol CurrentRow = b3
main:
debug
for CurrentRow = Row1 to Row4
High CurrentRow
High PinsC
b2 = PinsC
if CurrentRow = Row1 then
if b2 = Num1 then
PinPressed1 = 1
elseif b2 = Num2 then
PinPressed1 = 2
elseif b2 = Num3 then
PinPressed1 = 3
endif
Endif
If CurrentRow = Row2 then
if b2 = Num1 then
PinPressed2 = 4
elseif b2 = Num2 then
PinPressed2 = 5
elseif b2 = Num3 then
PinPressed2 = 6
endif
Endif
If CurrentRow = Row3 then
if b2 = Num1 then
PinPressed3 = 7
elseif b2 = Num2 then
PinPressed3 = 8
elseif b2 = Num3 then
PinPressed3 = 9
endif
Endif
If CurrentRow = Row4 then
if b2 = Num1 then
PinPressed4 = "*"
elseif b2 = Num2 then
PinPressed4 = 0
elseif b2 = Num3 then
PinPressed1 = 0
PinPressed2 = 0
PinPressed3 = 0
PinPressed4 = 0
endif
Endif
Low PinsC
Low CurrentRow
next
CurrentRow = 4
gosub Digit1
goto main
' PIN IS 25842
Digit1:
if PinPressed1 = 2 then
goto Digit2
Endif
Digit2:
if PinPressed2 = 5 then
goto Digit3
Endif
Digit3:
if PinPressed3 = 8 then
goto Digit4
Endif
Digit4:
if PinPressed4 = 42 then
high B.3
else
low B.3
Endif
return
As you can see the pin is 25842 (the 42 is from the "*")
so the code i have used means you can only have one digit from each row for example if you input 3 in the first row PinPressed1 will change to 3 but then if you put 4 in the second row PinPressed2 = 4 however then for the 3rd digit if you input 1 the PinPressed1 variable changes from 3 to 1.
How can i do it like a concatenation? and then i check if the concatenated string is equal to 25842?
I hope i explained it well
Alex