Would you like to react to this message? Create an account in a few clicks or log in to continue.

    PIC16F84 ile programlanabilir şifreli kilit devresi

    Admin
    Admin
    Root Administrator
    Root Administrator


    Mesaj Sayısı : 97
    Rep Puanı : 220
    Kayıt tarihi : 18/02/10
    Yaş : 33
    Nerden : Nereye

    PIC16F84 ile programlanabilir şifreli kilit devresi Empty PIC16F84 ile programlanabilir şifreli kilit devresi

    Mesaj tarafından Admin Cuma Mart 05, 2010 1:23 pm

    Devre şeması;
    PIC16F84 ile programlanabilir şifreli kilit devresi 333333333333k
    piccodelock.bas yazılımı;'****************************************************************
    '* Name : CodeLock.bas *
    '* Author : F. San *
    '* Date : 18.12.2003 *
    '* Version : 1.0 *
    '* Notes : Programable Code Lock with the PIC-16F84 *
    '****************************************************************

    @ device xt_osc, wdt_off, pwrt_on, protect_off

    '**************************************************
    RL1_ON_time con 1000 * 3 'sec. Relay ON time
    '**************************************************

    TrisA = 0 ' PORTA, all outputs
    PortA = 16 ' turn off Buzer
    OPTION_REG.7 = 0 ' PORTB Pullups.
    TrisB = 110000 ' PORTB.0-3 outputs, 4-7 inputs
    PortB = 0

    LD1 var PortA.2
    RL1 var PortA.3
    BUZ var portA.4
    cnt var byte

    key var byte
    col var byte
    row var byte
    keycnt var byte
    pwOK var bit

    keybuf var byte[15]
    pwbuf var byte[4]

    EEPROM 0,[1,2,3,4] 'Default password 1,2,3,4 programmed at EEprom location 0..3
    Read 0, pwbuf[0] 'Copy password from EEprom address 0..3 in to pwbuf[0..3]
    Read 1, pwbuf[1]
    Read 2, pwbuf[2]
    Read 3, pwbuf[3]

    pwOK = 0
    keycnt = 0

    Main:
    high ld1
    gosub Chk_KEYPAD
    pause 1
    goto Main

    Chk_KEYPAD:
    for row = 0 to 3
    PORTB = (dcd row) ^ $f
    pause 1
    col = PORTB >> 4
    if (col <> $f) then 'key pressed
    key = (row * 3) (ncd (col ^ $f))
    gosub Got_KEY
    key = 255
    endif
    next
    return

    Beep:
    low ld1
    low buz
    pause 40
    high buz
    return

    Got_KEY:
    gosub Beep
    while (PORTB >> 4) <> $f
    pause 1
    wend
    if key = 11 then key = 0
    keybuf[keycnt] = key
    gosub Chk_keycnt
    return

    Chk_PwOK:
    PwOK = 0
    if (keybuf[0] = pwbuf[0]) and (keybuf[1] = pwbuf[1]) and (keybuf[2] = pwbuf[2]) and (keybuf[3] = pwbuf[3]) then pwok = 1
    return

    Chk_NewPwOK:
    PwOK = 0
    if (keybuf[5] = keybuf[10]) and (keybuf[6] = keybuf[11]) and (keybuf[7] = keybuf[12]) and (keybuf[8] = keybuf[13]) then pwok = 1
    return

    Pw_Change:
    pwbuf[0] = keybuf[5]
    pwbuf[1] = keybuf[6]
    pwbuf[2] = keybuf[7]
    pwbuf[3] = keybuf[8]
    Write 0, pwbuf[0] 'Store new password to EEprom location 0..3
    Write 1, pwbuf[1]
    Write 2, pwbuf[2]
    Write 3, pwbuf[3]
    return

    Chk_keycnt:
    select case keycnt
    case 4
    gosub Chk_PwOK
    if pwOK then
    if keybuf[keycnt] = 12 then Access_OK
    if keybuf[keycnt] <> 10 then Clr_keybuf
    gosub Beep
    else
    goto Clr_keybuf
    endif
    case 9
    if keybuf[keycnt] <> 12 then Clr_keybuf
    gosub Beep
    case 14
    if keybuf[keycnt] <> 12 then Clr_keybuf
    gosub Beep
    gosub Chk_NewPwOK
    if pwOK then
    gosub Beep
    gosub Pw_Change
    gosub Beep
    goto Clr_keybuf
    else
    goto Clr_keybuf
    endif
    case else
    if keybuf[keycnt] = 12 then Clr_keybuf
    end select
    keycnt = keycnt 1
    return

    Access_OK:
    High RL1
    pause RL1_ON_time
    low RL1

    Clr_keybuf:
    for cnt = 0 to 14
    keybuf[cnt] = cnt
    next
    keycnt = 0
    goto Main

    end

      Forum Saati Cuma Mayıs 10, 2024 6:25 pm