PDA

View Full Version : How to drive 7 segment using multiple ports?



guess79
- 11th December 2006, 16:21
Dear All, How can I drive 7 segment display with 16F84 using multiple ports (portA.0~3 together with PortB.4~7)?

e.g
' A0 : segment a
' A1 : segment b
' A2 : segment c
' A3 : segment d
' B4 : segment e
' B5 : segment f
' B6 : segment g
' B7 : segment decimal dot

Can any one help me with the following code, please

=================================
digit var Byte
mask var Byte
i var Byte
TRISB = %00000000
TRISA = %00000

loop:

For i = 0 To 9
LookUp, digit (0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x07, 0x7f, 0x6f), mask
"PORTA(A0~A3) + PortB(B4~7) " = mask <--------------- send mask munber to both portA+ portB; this is where i have problem!!!!!!
pause 500
Next i
Goto loop
end

Bruce
- 11th December 2006, 17:10
Here's a good start http://melabs.com/resources/articles/ledart.htm

mister_e
- 11th December 2006, 17:10
look at this
http://melabs.com/resources/articles/ledart.htm

and this
http://www.picbasic.co.uk/forum/showthread.php?t=1044

EDIT: Seems bruce hit the button at the same time :D

SOMRU
- 11th December 2006, 19:43
EEPROM 0,[129,243,73,97,51,37,5,241,1,49] 'STORE CONSTANTS



LOOP1: 'DISPLAY T & A
FOR C = 0 TO 3
READ T DIG C, PORTB 'GRAB NUMBER AND SET SEGMENTS
LOOKUP C,[$7F,$BF,$DF,$EF],PORTC 'SET DIGIT
PAUSE f 'PAUSE ON
PORTC = $FF 'CLEAR PORT
NEXT C 'NEXT NUMBER OF 4
FOR B = 0 TO 3 'LOOP AGAIN FOR SECOND ROW
READ AS DIG B, PORTB
LOOKUP B,[$FE,$FD,$FB,$F7],PORTC
PAUSE f
PORTC = $FF
NEXT B
GOTO LOOP