i am glad that finaly your program works as you wanted. Make sure to add the two corrections in red, to your code, otherwise you could experiment some wierd behaviour.
Code:
include "modedefs.bas"
define osc 4
porta = 1
portb = 0
key var bit [7]
key1 var bit [7]
adr var byte
cod var byte
symbol sclk = portb.0
symbol sdat = portb.1
symbol buz = portb.2
symbol led1 = portb.4
symbol rely = portb.3
symbol strt = porta.0
symbol unlck = porta.1
symbol blck = porta.2
start:
If strt = 0 then gosub scan
if blck = 0 then goto angry
if strt = 1 then
high led1
pause 100
low led1
if strt = 0 then gosub scan
if blck = 0 then goto angry
pause 100
endif
goto start
scan:
For adr = 0 to 7
i2cread sdat,sclk,$a0,adr,[key]
read adr,key1
if key != key1 then error ' not gosub error
if (key == key1) then cod = 1
if rely = 1 then serout led1,n2400,["its unlocked hero"]
next adr
pause 10
rely = cod
pause 2000
low rely
return
angry:
Sound buz,[102,75]
high led1
pause 1000
sleep 30
nop
sound buz,[102,75]
pause 1000
goto start
error:
Low rely
sound buz,[102,75]
pause 1000
high led1
pause 1000
low led1
pause 1000
sound buz,[102,75]
high led1
sound buz,[102,75]
sleep 10
return ' not goto start
end
data @0,$14,$21,$47,$56,$02,$11,$22,$33
Bookmarks