7 segment display question
kyle k
Posts: 1
I am using the 7 segment display· ( two digits) to display the output distance of the ping sensor.
I am having problems with the 7 segment display.
I would like to display the output of the ping sensor in two seven segment displays.
here is my code for 7 segment display
'
[noparse][[/noparse] I/O Definitions ]
Segs VAR OUTL ' Segments on P0 - P7
Digs VAR OUTD ' Digit control pins
'
[noparse][[/noparse] Variables ]
theDig VAR Word ' current display digit
inDistance VAR Word ' distance of ping sensor in inches
'
[noparse][[/noparse] EEPROM Data ]
Digit0 DATA %00111111 ' digit patterns
Digit1 DATA %00000110
Digit2 DATA %01011011
Digit3 DATA %01001111
Digit4 DATA %01100110
Digit5 DATA %01101101
Digit6 DATA %01111101
Digit7 DATA %00000111
Digit8 DATA %01111111
Digit9 DATA %01100111
DigSel DATA %1110 ' digit 0 active
········ DATA %1101 ' digit 1 active
radar_display:
Segs = Blank ' clear display
IF INDistance < 10 THEN
· READ (DigSel +· inDistance), Digs ' select digit
· READ (Digit0 + (indistance DIG thedig)), Segs ' move digit pattern to segs
· thedig = thedig + 1 // 4 ' update digit pointer
ELSE
· READ (DigSel +· inDistance), Digs ' select digit
· READ (Digit1 + (indistance DIG thedig)), Segs ' move digit pattern to segs
· thedig = thedig + 1 // 4 ' update digit pointer
ENDIF
RETURN
I am having problems with the 7 segment display.
I would like to display the output of the ping sensor in two seven segment displays.
here is my code for 7 segment display
'
[noparse][[/noparse] I/O Definitions ]
Segs VAR OUTL ' Segments on P0 - P7
Digs VAR OUTD ' Digit control pins
'
[noparse][[/noparse] Variables ]
theDig VAR Word ' current display digit
inDistance VAR Word ' distance of ping sensor in inches
'
[noparse][[/noparse] EEPROM Data ]
Digit0 DATA %00111111 ' digit patterns
Digit1 DATA %00000110
Digit2 DATA %01011011
Digit3 DATA %01001111
Digit4 DATA %01100110
Digit5 DATA %01101101
Digit6 DATA %01111101
Digit7 DATA %00000111
Digit8 DATA %01111111
Digit9 DATA %01100111
DigSel DATA %1110 ' digit 0 active
········ DATA %1101 ' digit 1 active
radar_display:
Segs = Blank ' clear display
IF INDistance < 10 THEN
· READ (DigSel +· inDistance), Digs ' select digit
· READ (Digit0 + (indistance DIG thedig)), Segs ' move digit pattern to segs
· thedig = thedig + 1 // 4 ' update digit pointer
ELSE
· READ (DigSel +· inDistance), Digs ' select digit
· READ (Digit1 + (indistance DIG thedig)), Segs ' move digit pattern to segs
· thedig = thedig + 1 // 4 ' update digit pointer
ENDIF
RETURN
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
pos = 0
workval = distance/10
gosub printdigit
pos = 1
workval = distance//10
gosub printdigit
printdigit:
' uses pos to determine which 7seg to light
' use workval as the digit to display
return