keypad + 7-segment


Closed Thread
Results 1 to 9 of 9
  1. #1
    evmav's Avatar
    evmav Guest

    Red face keypad + 7-segment

    Hallo to all
    my question is how to input 4-digit with 4x3 matrix keypad on 4-digit 7-segment corectly

    I am working on project with 4-digit 7-segment display and 4x3 matrix keypad (1,2,3,4,5,6,7,8,9,0,#,*) and 16f876. I have a trouble with writing on 7-seg display desired data.
    If i have to write 1234 for example , i see on the 7-seg 4321.
    Please advise me what to do.
    thanks .

  2. #2
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by evmav
    If i have to write 1234 for example , i see on the 7-seg 4321.
    Please advise me what to do.
    thanks .
    Write 4321, or adjust your write routine, or re-wire your 7-segment display.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  3. #3
    evmav's Avatar
    evmav Guest


    Did you find this post helpful? Yes | No

    Default

    I mean when i write 2-digit , 3-digit or 4-digit number, the last lead digit to be unit, the one before last to be tenth, and so ...the first one to be thousanth....

  4. #4
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Can you post the code you have with a schematic showing how you have the displays wired?
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  5. #5
    Rhatidbwoy's Avatar
    Rhatidbwoy Guest


    Did you find this post helpful? Yes | No

    Default

    I had a problem like this when I had this lab in school. Couple years to follow a simple thought process of how to write it could be changed.

    A method you can try is like this:
    1. input your data into 1st 7seg
    2. take the old data from 1st 7seg and put into 2nd 7seg.
    3. so forth

    Doing this you will have 3 var that will store the information that does travel from one 7seg to the next. That is something you have to figure for you program. Draw it out then write it out.

  6. #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.

  7. #7
    Rhatidbwoy's Avatar
    Rhatidbwoy Guest


    Did you find this post helpful? Yes | No

    Default

    what is happeing when you switch the code?

  8. #8
    Join Date
    Mar 2006
    Posts
    41


    Did you find this post helpful? Yes | No

    Default keypad+7segment

    i had the same problem a couple of days ago one solution is to flag the number of keypad hits then after every flag perform an operation i used flags from 1 to 4 then save the keypad hits in 4 variables then do an operation each and every flags!!! for example to solve a digit or two flag1 which is keypad hit number one = hit1, flag2= (hit1*10)+hit2 then flag3=(hit1*100)+(hit2*10)+hit3............and so on and so forth

  9. #9


    Did you find this post helpful? Yes | No

    Wink keypad + 7-segment

    Hello,

    It publishes the complete code to be able to help you.

    Greetings

    Leonard


    Quote Originally Posted by leisryan
    i had the same problem a couple of days ago one solution is to flag the number of keypad hits then after every flag perform an operation i used flags from 1 to 4 then save the keypad hits in 4 variables then do an operation each and every flags!!! for example to solve a digit or two flag1 which is keypad hit number one = hit1, flag2= (hit1*10)+hit2 then flag3=(hit1*100)+(hit2*10)+hit3............and so on and so forth

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 : 1

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