Thanks Steve.
I have the array working now, thanks to Pedja089 (Thanks!) and thanks to Steve (EarlyBird2) I have the bit manipulation going.
I have a solution using bit manipulation and Select Case statements which work completely and is more readable than my early attempts at multiple if the statements.
The array idea works well except I can't seem to figure out the timing; on 2 inputs (9 and 11) I have a timing function where an output stays high for 2 seconds then goes low.
For the array, I use
and to get the table data is useCode:Table var byte[16] BANKA 'Array input is the value of the 4 inputs; 0-15 from the binary weight tflag var table.3 'timer flag TableIn var byte 'Entry into array from inputs temp var byte 'Temp var to use as a debounce
And for the main part I tried to useCode:Table[0]=6 Table[1]=2 Table[2]=6 Table[3]=2 Table[4]=6 Table[5]=6 Table[6]=6 Table[7]=6 Table[8]=5 ' Table[9]=0 Table[10]=5 ' Table[11]=0 Table[12]=4 Table[13]=6 Table[14]=6 Table[15]=6
I use the timing function which seems to work for 1 condition but when I typeCode:'######################################################################################################################### '# Subroutines '######################################################################################################################### Wait2sec: pause 2000 return get_input: TableIn=PORTA & %00110011 'Selects the correct input pins TableIn=(TableIn & %00000011) + (TableIn & %00110000)>>2 'Selects A0,A1 then selects A4,A5 moves to A2, A3 and adds to A0,A1 'Therefore, the array entry is (Command - DPI - Bolt - Deadlck) return '######################################################################################################################### '# Startmain - where the MAGIC starts! '######################################################################################################################### Startmain: 'Main wait loop gosub get_input 'Get inputs temp=TableIn pause 100 gosub get_input if TableIn <> temp then goto startmain 'Var and temp var did not match so must have been noise, go back if TableIn = 9 then if tflag=1 then Main1X unlock=0 unsecure=0 lock=1 pause 2000 lock=0 tflag=1 Main1X: lock=0 unlock=0 unsecure=0 goto startmain endif PORTC=Table[TableIn] 'Sets the port output to the table byte goto startmain 'Start all over
if TableIn = 9 or 11 then
as a substitute for just 1 function, it bombs.
The time flag beinig reset for all of the other conditions works for 1 condition but not for an OR condition?
What am I missing now?
-Steve




Bookmarks