how to compare data


Closed Thread
Results 1 to 20 of 20

Hybrid View

  1. #1
    Join Date
    May 2009
    Posts
    66


    Did you find this post helpful? Yes | No

    Default

    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

  2. #2
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    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.

    Al.


    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
    '
    All progress began with an idea

  3. #3
    Join Date
    May 2009
    Posts
    66


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by aratti View Post
    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.

    Al.


    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
    '
    thank u aratti for help i jsut want to make pic goes sleep and wake it when i push abottom or some im new in pbp help me if u can thnk u again

  4. #4
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    want to make pic goes sleep and wake it when i push abottom
    To do that you need to re-wire your circuit and use portB.0 as your push-button detector. (now you are using portB.0 for I2C communication)

    Once you have done that, you will need to learn how to use and activate the interrupt on portB.0, because this will wakeup your sleeping MCU.

    I strongly suggest you to look at Darrel Taylor instant interrupt and experiment a while with it and then use it to improve your program.

    Have a look @ http://darreltaylor.com/DT_INTS-14/hello.html

    Al.
    Last edited by aratti; - 30th October 2009 at 08:32.
    All progress began with an idea

  5. #5
    Join Date
    May 2009
    Posts
    66


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by aratti View Post
    To do that you need to re-wire your circuit and use portB.0 as your push-button detector. (now you are using portB.0 for I2C communication)

    Once you have done that, you will need to learn how to use and activate the interrupt on portB.0, because this will wakeup your sleeping MCU.

    I strongly suggest you to look at Darrel Taylor instant interrupt and experiment a while with it and then use it to improve your program.

    Have a look @ http://darreltaylor.com/DT_INTS-14/hello.html

    Al.
    i found out. and it works great pic goes to sleep when u dont press bottoms after 1 mnt.using PB.0 for int and some beeps when wake up, so it works ok thank you aratti for helping me.im new in pbp i still donno about timers adc many things and no assembler at all lol

Similar Threads

  1. Using Nokia LCD
    By BobP in forum mel PIC BASIC Pro
    Replies: 300
    Last Post: - 3rd May 2018, 04:47
  2. Nokia 3310 display text
    By chai98a in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 26th August 2007, 03:39
  3. Big characters on HD44780 4x20
    By erpalma in forum mel PIC BASIC Pro
    Replies: 23
    Last Post: - 7th January 2007, 02:21
  4. LCD + bar graph
    By DynamoBen in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 5th October 2005, 14:50
  5. Sinus calculating !
    By Don Mario in forum mel PIC BASIC Pro
    Replies: 29
    Last Post: - 28th November 2004, 23:56

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts