keypad + 7-segment


Results 1 to 9 of 9

Threaded View

  1. #6
    evmav's Avatar
    evmav Guest


    Did you find this post helpful? Yes | No

    Default

    i changed some things, but there is something wrong again....here is my code:

    INCLUDE "modedefs.bas"
    Flag Var Bit
    Key Var Byte
    Resultat Var Byte
    s var byte ' KOLKO PUTI SYM NATISNAL KLAVIATURATA
    W VAR WORD ' tova e nabranoto chislo ot klaviaturata
    BCD1 VAR BYTE
    BCD2 VAR BYTE
    BCD3 VAR BYTE
    BCD4 VAR BYTE
    symbol Segmenti = PORTC
    symbol razriad = PORTA
    i Var Byte
    n Var Byte
    TRISA = 0
    TRISB = %11110001
    trisc = 0
    INTCON = %10000000
    W = 0
    Resultat = 0
    S = 0
    bcd1 = 0
    bcd2 = 0
    BCD3 = 0
    bcd4 = 0

    Main:
    Gosub ScanKeys

    if resultat = 11 then TOGGLE PORTA.4
    if resultat = 10 THEN TOGGLE PORTA.5
    IF resultat = 12 then Main

    SELECT CASE S
    CASE 0
    segmenti = $3F '0
    razriad = 1 'LSDigit
    GOTO MAIN
    CASE 1
    w= resultat
    bcd1 = resultat
    CASE 2
    bcd2 = resultat
    w = bcd1*10 + bcd2
    CASE 3
    bcd3= resultat
    w = bcd1*100 + bcd2*10 + bcd3
    CASE 4
    bcd4 = resultat
    w = bcd1*1000 + bcd2*100 + bcd3*10 + bcd1
    CASE ELSE
    S= 0
    GOTO MAIN

    END SELECT
    gosub pokaji

    ScanKeys:

    Key=0

    PORTB=%1000
    gosub Redica
    if Flag=1 then Kolona1

    PORTB=%0100
    gosub Redica
    if Flag=1 then Kolona2

    PORTB=%0010
    gosub Redica
    if Flag=1 then Kolona3

    Resultat=12
    return

    Kolona1:
    s = s+1
    lookup Key,[1,4,7,10],Resultat
    return

    Kolona2:
    s = s+1
    lookup Key,[2,5,8,0 ],Resultat
    return

    Kolona3:
    s = s+1
    lookup Key,[3,6,9,11],Resultat
    return

    Redica:
    Flag=1
    if PORTB.4=1 then return
    Key=Key+1

    if PORTB.5=1 then return
    Key=Key+1

    if PORTB.6=1 then return
    Key=Key+1

    if PORTB.7=1 then return
    Key=Key+1
    Flag=0

    return

    pokaji:
    For i = 0 To s
    n = W Dig i
    GoSub izvlechi
    Next i
    Return

    izvlechi:

    Lookup n, [$3f, $06, $5b, $4f, $66, $6d, $7d, $07, $7f, $6f], Segmenti
    razriad = Dcd i


    Return

    end



    and here is a sheme
    Attached Images Attached Images  
    Last edited by evmav; - 3rd February 2006 at 14:30.

Similar Threads

  1. LED Machine Tach For Tired Eyes
    By Archangel in forum mel PIC BASIC Pro
    Replies: 33
    Last Post: - 27th January 2010, 14:55
  2. Replies: 1
    Last Post: - 6th April 2007, 10:50
  3. How to drive 7 segment using multiple ports?
    By guess79 in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 11th December 2006, 19:43
  4. 7 segment digit problem (using Mister E's code)
    By jmgelba in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 9th September 2005, 20:25
  5. WRITE not working
    By servo260 in forum mel PIC BASIC Pro
    Replies: 31
    Last Post: - 29th December 2004, 02:02

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