PDA

View Full Version : keypad + 7-segment



evmav
- 2nd February 2006, 10:58
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 .

Bruce
- 2nd February 2006, 14:27
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.

evmav
- 2nd February 2006, 15:01
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....

Bruce
- 2nd February 2006, 15:29
Can you post the code you have with a schematic showing how you have the displays wired?

Rhatidbwoy
- 2nd February 2006, 17:22
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.

evmav
- 3rd February 2006, 09:48
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

Rhatidbwoy
- 3rd February 2006, 18:35
what is happeing when you switch the code?

leisryan
- 27th May 2006, 19:47
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

Leonardo
- 19th June 2006, 19:40
Hello,

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

Greetings

Leonard



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