axscont.tmb for the DR51 Access controller using keypad and relay ------------------------------- NEW --- store non-changable "master" code in EEPROM 1 B=255 2 A=9 3 WRITEEE 220 4 B=255 5 A=9 6 WRITEEE 221 7 B=255 8 A=9 9 WRITEEE 222 --- store changable "user" code in EEPROM 10 B=255 11 A=1 12 WRITEEE 223 13 B=255 14 A=2 15 WRITEEE 224 16 B=255 17 A=3 18 WRITEEE 225 --- main loop exit if key on PC keyboard is hit 20 A=KEY 21 IF A<>0 0 wait for keypad entry 22 GOSUB 150 23 IF A=0 20 --- see if master code matches 30 READEE 220 31 B=D 32 IF A<>B 70 33 READEE 221 34 B=E 35 IF A<>B 70 36 READEE 222 37 B=F 38 IF A<>B 70 --- good master code entered, get new user code prompt flashes 40 DELAY 10 41 LOOP 3 42 LED=1 43 DELAY 3 44 LED=0 45 DELAY 3 46 ENDLOOP wait for complete new code 47 GOSUB 150 48 IF A=0 47 49 B=255 50 A=D 51 WRITEEE 223 52 B=255 53 A=E 54 WRITEEE 224 55 B=255 56 A=F 57 WRITEEE 225 confirmation flashes 58 DELAY 10 59 LOOP 3 60 LED=1 61 DELAY 3 62 LED=0 63 DELAY 3 64 ENDLOOP 65 GOTO 20 --- see if user code matches 70 READEE 223 71 B=D 72 IF A<>B 100 73 READEE 224 74 B=E 75 IF A<>B 100 76 READEE 225 77 B=F 78 IF A<>B 100 --- good user code entered, operate relay while flashing LED quickly 80 RELAY1=1 81 LOOP 20 82 LED=1 83 DELAY 1 84 LED=0 85 DELAY 1 86 ENDLOOP 87 RELAY1=0 88 GOTO 20 --- wrong code entered, flash LED slowly in error 100 DELAY 10 101 LOOP 10 102 LED=1 103 DELAY 5 104 LED=0 105 DELAY 5 106 ENDLOOP 107 GOTO 20 --- Check keypad for 3 digit number being entered. If no key is pressed return A=0, just like READKP. If key is pressed, store it in D and wait for 2 more keys, then store them in E and F and return with A=1. Wait only a specified time for each key or else return with A=0. LED acknowledges keys. Lines 160/180 are time to wait in tenth seconds. Key pressed must be released before checking for next. 150 READKP 151 IF A<>0 153 152 RETURN 153 D=B 154 LED=1 155 DELAY 1 156 LED=0 157 READKP 158 IF A<>0 157 159 DELAY 1 160 C=20 161 LOOP 50 162 READKP 163 IF A<>0 170 164 ENDLOOP 165 A=C 166 A=A-1 167 C=A 168 IF A<>0 161 169 RETURN 170 E=B 171 LED=1 172 DELAY 1 173 LED=0 174 READKP 175 IF A<>0 174 176 DELAY 1 180 C=20 181 LOOP 50 182 READKP 183 IF A<>0 190 184 ENDLOOP 185 A=C 186 A=A-1 187 C=A 188 IF A<>0 181 189 RETURN 190 F=B 191 LED=1 192 DELAY 1 193 LED=0 194 READKP 195 IF A<>0 194 196 DELAY 1 197 A=1 198 RETURN --- assign I/O signals to keypad rows and columns 230 PRINT 8 231 PRINT 7 232 PRINT 6 233 PRINT 5 234 PRINT 4 235 PRINT 3 236 PRINT 2 237 PRINT 1 --- assign values to keypad switches note that the following values are not enclosed in quotes, meaning that READKP returns these values, not their characters 240 PRINT 1 241 PRINT 2 242 PRINT 3 244 PRINT 4 245 PRINT 5 246 PRINT 6 248 PRINT 7 249 PRINT 8 250 PRINT 9 252 PRINT 27 253 PRINT 0 254 PRINT 13