Well now that we've solved the problem of the subscript error, i would like to ask for help with my program.
I'm using the 18X as a decoder. I have a 4x3 way matrix keypad. The rows are connected to 4 outputs from the chip (0-3) then fed back, though current limiting resistors to 3 inputs. By scanning through the outputs and inputs, when a certain key is pressed a certain output and a certain input will be high, thus the number can be determined.
The inputs are held low with 10k resistors to stop them floating (these were once removed to test if these were the fault described below, but to no effect.)
Here is the code, i will explain the problem at the end:
<code><pre><font size=2 face='Courier'>
'b0 is the code to be transmitted
main:
'this looks for the entry of the # key to show that a code is being entered
lookforhash: high 6 'Red LED
high 4
if pin0=1 then goto getcode 'waits for a # before beginning transmission of code
goto lookforhash
'this works out which number was pressed
getcode: low 6 'low Red LED
high 5 'High Orange LED
high 1 'checks for 1, 2 or 3
if pin2=1 then press1
if pin1=1 then press2
if pin0=1 then press3
low 1
high 2 'checks for 4, 5 or 6
if pin2=1 then press4
if pin1=1 then press5
if pin0=1 then press6
low 2
high 3 'checks for 7, 8 or 9
if pin2=1 then press7
if pin1=1 then press8
if pin0=1 then press9
low 3
high 4 'checks for 0 OR press of * indicating completion of code entry
if pin1=1 then press0
if pin2=0 then goto lookforhash
low 4
goto getcode
'this sends the code to the computer
transmitcode: 'serout 7, t2400, (b0) 'sends the number just entered to the computer
high 4 'Green LED high
sertxd (#b0)
pause 1000 'puts a break in
low 4 'green LED low
goto getcode 'checks for the next number
'the following sets b0 to the number entered
press1: let b0=1
goto transmitcode 'goes to seriel transmission
press2: let b0=2
goto transmitcode 'goes to seriel transmission
press3: let b0=3
goto transmitcode 'goes to seriel transmission
press4: let b0=4
goto transmitcode 'goes to seriel transmission
press5: let b0=5
goto transmitcode 'goes to seriel transmission
press6: let b0=6
goto transmitcode 'goes to seriel transmission
press7: let b0=7
goto transmitcode 'goes to seriel transmission
press8: let b0=8
goto transmitcode 'goes to seriel transmission
press9: let b0=9
goto transmitcode 'goes to seriel transmission
press0: let b0=0
goto transmitcode 'goes to seriel transmission
</font></pre></code>
As you can see it spends most of its time looking for the Hash key, but unfortunatly at the moment this is all it spends it doing. I've tried pushing every other key incase of a wiring mistake, but to no avail.
Any suggestions as to why it is not moving on would be appreciated.
Also any suggestions as to how to tidy the code (not that i need the space, but this is my Software Design major project, and i want it to look tidy.)
I'm using the 18X as a decoder. I have a 4x3 way matrix keypad. The rows are connected to 4 outputs from the chip (0-3) then fed back, though current limiting resistors to 3 inputs. By scanning through the outputs and inputs, when a certain key is pressed a certain output and a certain input will be high, thus the number can be determined.
The inputs are held low with 10k resistors to stop them floating (these were once removed to test if these were the fault described below, but to no effect.)
Here is the code, i will explain the problem at the end:
<code><pre><font size=2 face='Courier'>
'b0 is the code to be transmitted
main:
'this looks for the entry of the # key to show that a code is being entered
lookforhash: high 6 'Red LED
high 4
if pin0=1 then goto getcode 'waits for a # before beginning transmission of code
goto lookforhash
'this works out which number was pressed
getcode: low 6 'low Red LED
high 5 'High Orange LED
high 1 'checks for 1, 2 or 3
if pin2=1 then press1
if pin1=1 then press2
if pin0=1 then press3
low 1
high 2 'checks for 4, 5 or 6
if pin2=1 then press4
if pin1=1 then press5
if pin0=1 then press6
low 2
high 3 'checks for 7, 8 or 9
if pin2=1 then press7
if pin1=1 then press8
if pin0=1 then press9
low 3
high 4 'checks for 0 OR press of * indicating completion of code entry
if pin1=1 then press0
if pin2=0 then goto lookforhash
low 4
goto getcode
'this sends the code to the computer
transmitcode: 'serout 7, t2400, (b0) 'sends the number just entered to the computer
high 4 'Green LED high
sertxd (#b0)
pause 1000 'puts a break in
low 4 'green LED low
goto getcode 'checks for the next number
'the following sets b0 to the number entered
press1: let b0=1
goto transmitcode 'goes to seriel transmission
press2: let b0=2
goto transmitcode 'goes to seriel transmission
press3: let b0=3
goto transmitcode 'goes to seriel transmission
press4: let b0=4
goto transmitcode 'goes to seriel transmission
press5: let b0=5
goto transmitcode 'goes to seriel transmission
press6: let b0=6
goto transmitcode 'goes to seriel transmission
press7: let b0=7
goto transmitcode 'goes to seriel transmission
press8: let b0=8
goto transmitcode 'goes to seriel transmission
press9: let b0=9
goto transmitcode 'goes to seriel transmission
press0: let b0=0
goto transmitcode 'goes to seriel transmission
</font></pre></code>
As you can see it spends most of its time looking for the Hash key, but unfortunatly at the moment this is all it spends it doing. I've tried pushing every other key incase of a wiring mistake, but to no avail.
Any suggestions as to why it is not moving on would be appreciated.
Also any suggestions as to how to tidy the code (not that i need the space, but this is my Software Design major project, and i want it to look tidy.)