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.
Bookmarks