Quote Originally Posted by malwww View Post
hi joe, im using dsr display which has ic 74hc164 and 4 wires for each digits now i know there no ports output to count digits throu the lcd ,and ur code it works just 1 digit when i plug 1 dgit wire to the GND, i wanted to enable each port to change digits for shiftout and i use pic16f84, sorry for bothering you that much joe and thank you so much for teaching me ,


define _config _INTRC_OSC_NOCLKOUT & _WDT_ON & _PWRTE_ON & _MCLRE_OFF &_CP_OFF & _BODEN_OFF & _LVP_OFF

DEFINE OSC 4

SDO Var PortB.4
SCLK Var PortB.5
DLE Var PortB.7
EECON1 = 7
B0 Var WORD
B1 Var byte

D1 Var byte
D10 Var byte
D100 Var byte
D1000 Var byte
ONES Var Byte
TENS Var Byte
HUNS Var Byte
THOUS Var Byte
'WPUA = %00110001
'ANSEL = 0 ' FOR USE IN 16F690
'ANSELH = 0
'CCP1CON = 0
'CM1CON0 = 0
'CM2CON0 = 0
'CMCON = 7 ' Disable comparators 16F648A
OPTION_REG = 0 '16f628a
'OPTION_REG = %00111000 ' set for 16f690
data @0,252,96,218,242,102,182,190,224,254,246
Pause 10
PORTB = 0
PORTA = 0
TRISB = %00000000 ' lower 4 pins outputs
TRISA = %00001 ' RA2 = TMR0 clock input

Main:

B0 = B0+B1 'STORE THE RESULTS BETWEEN COUNTER LOOPS
If B0 >= 9999 then B0 = 0

D1 = b0 DIG 0 ' Load Thousands Digit
Read D1, ONES ' Convert and Load Thousands Variable

d10 = B0 DIG 1 ' Load Hundreds Digit
READ D10,TENS ' Convert and Load Hundreds Variable

D100 = B0 DIG 2 ' Load Tens Digit
READ D100,HUNS ' Convert and Load Tens Variable

D1000 = B0 3 ' Load Ones Digit
READ D1000,THOUS ' Convert and Load Ones Variable

Shiftout SDO,SCLK,4,[ONES\8,TENS\8,HUNS\8,THOUS\8] 'when it shiftout it needs to eneble each digits bcz i have 4 wires i 'donno where i add them in this code so when it shiftout the 0 dig it enebles digit 1 on lcd then 2 so on i use digital satellite receiver 7 segments 4 digit it has 74hc164 for serial input data and clock then paralil output to 7 segments and each 1 wire ,from each digit i wanted to plug them in the pic so i need to eddit the code im still trying lol'
PAUSE 10
HIGH PORTB.7
pulsout DLE, 125
pause 12
Goto MAIN

end
OK, it took some hair pulling as I am not really good with arrays.
here is a sample as to how to do this. What you want to do is load the variable with the value to display, and display that digit, then do the next and the next. Using an array to hold the value:
Code:
Goldfish var byte ' cause it's late and I am tired
Digit var byte[4] ' 4 variables all named digit, an array
index var byte    ' a counting variable
displays var word ' from the program
digit_output var byte 'from the program
' this code changed from program
loop:
DIGIT_OUTPUT = DISPLAYS dig 0 ' Load Thousands Digit
READ DIGIT_OUTPUT, DIGIT.0    ' Convert and Load Thousands Variable
DIGIT_OUTPUT = DISPLAYS DIG 1 ' Load Hundreds  Digit
READ DIGIT_OUTPUT, DIGIT.1    ' Convert and Load Hundreds Variable
DIGIT_OUTPUT = DISPLAYS DIG 2 ' Load Tens of Units Digit
READ DIGIT_OUTPUT, DIGIT.2    ' Convert and Load Tens  Variable
DIGIT_OUTPUT = DISPLAYS dig 3 ' Load Ones of Units Digit
READ DIGIT_OUTPUT, DIGIT.3    ' Convert and Load Units Variable
' notice the digits were changed to reflect the array variable name
'here is where we do the magic
for index = 0 to 3  '  loop 4 times
Goldfish = digit[index]  ' load goldfish with the digit values
shiftout SDO,SCLK,4,[Goldfish\8]  ' send the values to display
portC.0[index] = 1 ' here we energise each display digit in sequence
PAUSEUS 900 ' this number alters the brightness verses display flash rate
PORTC=0 ' this blanks the numbers between loading data so it does not read 8888
next index ' select the next digit
 GOTO LOOP
you notice the word index in red, this syncronizes the digit selection on portc with the data being shifted out.