HELLO AND THANK U EVERYONES IS HELPING ME I DID IT LAST NIGHT AND I TRYED SO IT WORKS GREAT NOW IM USING F84 AND 24C02 SO I WILL DP IT FOR THE DOORLOCK AND THE EEPROM WILL BE IN THE KEY HERE IS MY CODE I IDDED SOME SLEEP AND BUZ SO MAYBE SOMEONE WILL NEED THIS CODE IT WORKS GOOD FOR LOCKS ALL WAT IM LOOKIN FOR NOW IS HOW TO WAKE UP PIC WHEN IT GOES SLEEP
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 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
GOTO START
END
DATA @0,$14,$21,$47,$56,$02,$11,$22,$33
EEPROM 24C02 SHOULD BE THE SAME ADDRESS AND DATA STORED THIS $14,$21,$47,$56,$02,$11,$22,$33 SO U CAN CHANGE THEM BOTH OR CHANGE THE ADRESS OR WATEVER IMNEW IN PBP . THANK U EVERYONES FOR HELP
Bookmarks